2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actorserviceprovider.impl;
24 import java.util.concurrent.Executor;
26 import org.onap.policy.controlloop.actorserviceprovider.Operator;
29 * Partial implementation of an operator.
31 public abstract class OperatorPartial extends StartConfigPartial<Map<String, Object>> implements Operator {
34 * Executor to be used for tasks that may perform blocking I/O. The default executor
35 * simply launches a new thread for each command that is submitted to it.
37 * The "get" method may be overridden by junit tests.
40 private final Executor blockingExecutor = command -> {
41 var thread = new Thread(command);
42 thread.setDaemon(true);
47 private final String actorName;
50 private final String name;
53 * Constructs the object.
55 * @param actorName name of the actor with which this operator is associated
56 * @param name operation name
58 protected OperatorPartial(String actorName, String name) {
59 super(actorName + "." + name);
60 this.actorName = actorName;
65 * Verifies that the operator is running.
67 * @throws IllegalStateException if it is not running
69 public void verifyRunning() {
71 throw new IllegalStateException("operation is not running: " + getFullName());
76 * This method does nothing.
79 protected void doConfigure(Map<String, Object> parameters) {
84 * This method does nothing.
87 protected void doStart() {
92 * This method does nothing.
95 protected void doStop() {
100 * This method does nothing.
103 protected void doShutdown() {