summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ExecutorFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ExecutorFactory.java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ExecutorFactory.java27
1 files changed, 11 insertions, 16 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ExecutorFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ExecutorFactory.java
index d0c1edc9fa..ee718f177b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ExecutorFactory.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ExecutorFactory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,19 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.components.distribution.engine;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
@Component("executorFactory")
/**
* Allows to create next kinds of single thread executors: SingleThreadExecutor and SingleThreadScheduledExecutor
@@ -38,26 +37,22 @@ public class ExecutorFactory {
private static final Logger logger = Logger.getLogger(EnvironmentsEngine.class.getName());
- public ExecutorService create(String name, UncaughtExceptionHandler exceptionHandler){
+ public ExecutorService create(String name, UncaughtExceptionHandler exceptionHandler) {
logger.info("Going to create single thread executor. ");
ThreadFactory threadFactory = createThreadFactory(name, exceptionHandler);
return Executors.newSingleThreadExecutor(threadFactory);
}
- public ScheduledExecutorService createScheduled(String name){
+ public ScheduledExecutorService createScheduled(String name) {
logger.info("Going to create single thread scheduled executor. ");
ThreadFactory threadFactory = createThreadFactory(name,
- (t, e) -> LoggerFactory.getLogger(UncaughtExceptionHandler.class).error("An error occurred: ", e));
+ (t, e) -> LoggerFactory.getLogger(UncaughtExceptionHandler.class).error("An error occurred: ", e));
return Executors.newSingleThreadScheduledExecutor(threadFactory);
}
private ThreadFactory createThreadFactory(String name, UncaughtExceptionHandler exceptionHandler) {
String nameFormat = name + "-%d";
- return new ThreadFactoryBuilder()
- .setThreadFactory(Executors.defaultThreadFactory())
- .setNameFormat(nameFormat)
- .setUncaughtExceptionHandler(exceptionHandler)
- .setDaemon(true)
- .build();
+ return new ThreadFactoryBuilder().setThreadFactory(Executors.defaultThreadFactory()).setNameFormat(nameFormat)
+ .setUncaughtExceptionHandler(exceptionHandler).setDaemon(true).build();
}
}