X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-be%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fsdc%2Fbe%2Fcomponents%2Fdistribution%2Fengine%2FExecutorFactory.java;h=ee718f177b4b99365c746a9052f85fe3210de336;hb=b1fc8c337d3b9750eff6e62b626c0bc3a1467a88;hp=d0c1edc9fac1ed09317e7d2be86ee6d093aef59d;hpb=260a951d3431429bab9732e16225e42641ae4787;p=sdc.git 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(); } }