summaryrefslogtreecommitdiffstats
path: root/common-be
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-01 20:58:10 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-03-01 21:00:16 +0000
commitdfc9cdee69426b48d683e119dda9fae9154e6fde (patch)
tree70e81d301bcc21b1d604b9f301176c9677dcb33d /common-be
parent97d15f764138e0d49963f168d339fc1637cc5376 (diff)
Improve test coverage
- remove unused code - use lombok Change-Id: I8c52584249347c7ca2102022457225401f95b9a5 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3490
Diffstat (limited to 'common-be')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/workers/Job.java29
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/workers/Main.java50
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/workers/Manager.java91
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/workers/Worker.java70
4 files changed, 0 insertions, 240 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/workers/Job.java b/common-be/src/main/java/org/openecomp/sdc/be/workers/Job.java
deleted file mode 100644
index 3ed2e5e83a..0000000000
--- a/common-be/src/main/java/org/openecomp/sdc/be/workers/Job.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.workers;
-
-/**
- * Created by michael on 6/24/2016.
- */
-public abstract class Job<E> {
- public abstract E doWork();
-
-}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/workers/Main.java b/common-be/src/main/java/org/openecomp/sdc/be/workers/Main.java
deleted file mode 100644
index 572cfe22e4..0000000000
--- a/common-be/src/main/java/org/openecomp/sdc/be/workers/Main.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.workers;
-
-/**
- * Created by michael on 6/24/2016.
- */
-public class Main {
-
- public static void main(String[] args) {
-
- Manager manger = new Manager();
- manger.init(2);
- manger.addJob(new Job() {
- @Override
- public String doWork() {
- return "go";
- }
- });
- manger.addJob(new Job() {
- @Override
- public String doWork() {
- return "go go";
- }
- });
- // try {
- System.out.println(manger.start());
- // } catch (InterruptedException e) {
- // e.printStackTrace();
- // }
- }
-}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/workers/Manager.java b/common-be/src/main/java/org/openecomp/sdc/be/workers/Manager.java
deleted file mode 100644
index bb426979ee..0000000000
--- a/common-be/src/main/java/org/openecomp/sdc/be/workers/Manager.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.workers;
-
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Created by michael on 6/24/2016.
- */
-public class Manager<T extends Job, E> {
- private static final int TERMINATION_TIMEAUT = 30;
- private static Logger log = Logger.getLogger(Manager.class.getName());
- private ExecutorService executor;
- private LinkedBlockingQueue<T> inputQueue;
- private LinkedBlockingQueue<E> outputQueue;
- private int numberOfWorkers;
-
- public void init(int numberOfWorkers) {
- log.debug("initializing workers, creating {} workers", numberOfWorkers);
- this.numberOfWorkers = numberOfWorkers;
- final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("Worker-%d").build();
- this.executor = Executors.newFixedThreadPool(numberOfWorkers, threadFactory);
- this.inputQueue = new LinkedBlockingQueue<>();
- this.outputQueue = new LinkedBlockingQueue<>();
- }
-
- public void addJob(T job) {
- log.trace("job add to input queue");
- this.inputQueue.add(job);
- }
-
- public LinkedBlockingQueue<E> start() {
- for (int i = 0; i < numberOfWorkers; i++) {
- String workerName = "worker-" + i;
- log.debug("starting worker:{}", workerName);
- this.executor.submit(new Worker(workerName, this.inputQueue, this.outputQueue));
- }
- executor.shutdown();
- try {
- if (!executor.awaitTermination(TERMINATION_TIMEAUT, TimeUnit.MINUTES)) {
- log.error("timer elapsed while waiting for the worker's to finish. ");
- }
- log.debug("all workers finished");
- } catch (InterruptedException e) {
- log.error("failed while waiting for", e);
- Thread.currentThread().interrupt();
- }
- return outputQueue;
- }
-
- //
- // public static void main(String[] args) {
- // ExecutorService executor = Executors.newFixedThreadPool(NTHREDS);
- // for (int i = 0; i < 500; i++) {
- // Runnable worker = new MyRunnable(10000000L + i);
- // executor.execute(worker);
- // }
- // // This will make the executor accept no new threads
- // // and finish all existing threads in the queue
- // executor.shutdown();
- // // Wait until all threads are finish
- // executor.awaitTermination();
- // System.out.println("Finished all threads");
- // }
- // }
-}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/workers/Worker.java b/common-be/src/main/java/org/openecomp/sdc/be/workers/Worker.java
deleted file mode 100644
index b5495760f2..0000000000
--- a/common-be/src/main/java/org/openecomp/sdc/be/workers/Worker.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.workers;
-
-import org.openecomp.sdc.be.config.BeEcompErrorManager;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Created by michael on 6/24/2016.
- */
-public class Worker<T extends Job<E>, E> implements Runnable {
-
- private static final int QUEUE_POLL_TIMEAUT = 500;
- private String workerName;
- private LinkedBlockingQueue<T> inputQueue;
-
- private LinkedBlockingQueue<E> outputQueue;
-
- private static Logger log = Logger.getLogger(Worker.class.getName());
-
- public Worker(String workerName, LinkedBlockingQueue<T> inputQueue, LinkedBlockingQueue<E> outputQueue) {
- this.workerName = workerName;
- this.inputQueue = inputQueue;
- this.outputQueue = outputQueue;
- }
-
- @Override
- public void run() {
-
- try {
- while (true) {
- log.trace("worker:{} doing work", workerName);
- T job = inputQueue.poll(QUEUE_POLL_TIMEAUT, TimeUnit.MILLISECONDS);
- if (job == null) {
-
- log.debug("worker:{} nothing to do");
- break;
- }
- this.outputQueue.put(job.doWork());
- log.trace("worker:{} done with work", workerName);
- }
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logInternalFlowError("executingJobFailed",
- "failed during job execution worker" + workerName, BeEcompErrorManager.ErrorSeverity.ERROR);
- log.debug("worker: {} nothing to do stoping", workerName, e);
- }
- }
-
-}