<relativePath>../../commons/binding-parent</relativePath>
</parent>
- <groupId>org.opendaylight.serviceutils</groupId>
<artifactId>srm-api</artifactId>
- <version>0.9.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<!-- <name> formatting is used by autorelease to parse and notify projects on
build failure. Please do not modify this unless you have a good reason. -->
void removeRecoverableListener(String serviceName, RecoverableListener recoverableListener);
Queue<RecoverableListener> getRecoverableListeners(String serviceName);
+
+ ServiceRecoveryInterface getRegisteredServiceRecoveryHandler(String entityName);
}
\ No newline at end of file
<relativePath>../../commons/quality-parent</relativePath>
</parent>
- <groupId>org.opendaylight.serviceutils</groupId>
<artifactId>srm-impl</artifactId>
- <version>0.9.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<!-- <name> formatting is used by autorelease to parse and notify projects on
build failure. Please do not modify this unless you have a good reason. -->
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>blueprint-maven-plugin-annotation</artifactId>
- <scope>provided</scope>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ </dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>blueprint-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
</project>
import javax.inject.Singleton;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.serviceutils.srm.ServiceRecoveryRegistry;
import org.opendaylight.serviceutils.tools.mdsal.listener.AbstractClusteredSyncDataTreeChangeListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.ServiceOps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.service.ops.Services;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.service.ops.services.Operations;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.EntityNameBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.EntityTypeBase;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.RequireServiceComponentRuntime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
-public class ServiceRecoveryListener extends AbstractClusteredSyncDataTreeChangeListener<Operations> {
-
+@Component
+@RequireServiceComponentRuntime
+public final class ServiceRecoveryListener extends AbstractClusteredSyncDataTreeChangeListener<Operations> {
private static final Logger LOG = LoggerFactory.getLogger(ServiceRecoveryListener.class);
- private final ServiceRecoveryManager serviceRecoveryManager;
+ private final ServiceRecoveryRegistry serviceRecoveryRegistry;
@Inject
- public ServiceRecoveryListener(DataBroker dataBroker, ServiceRecoveryManager serviceRecoveryManager) {
+ @Activate
+ public ServiceRecoveryListener(@Reference DataBroker dataBroker,
+ @Reference ServiceRecoveryRegistry serviceRecoveryRegistry) {
super(dataBroker, LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(ServiceOps.class)
.child(Services.class).child(Operations.class));
- this.serviceRecoveryManager = serviceRecoveryManager;
+ this.serviceRecoveryRegistry = serviceRecoveryRegistry;
}
@Override
+ @Deprecated
public void add(InstanceIdentifier<Operations> instanceIdentifier, Operations operations) {
LOG.info("Service Recovery operation triggered for service: {}", operations);
- serviceRecoveryManager.recoverService(operations.getEntityType(), operations.getEntityName(),
- operations.getEntityId());
+ recoverService(operations.getEntityType(), operations.getEntityName(), operations.getEntityId());
+ }
+
+ /**
+ * Initiates recovery mechanism for a particular interface-manager entity. This method tries to check whether there
+ * is a registered handler for the incoming service recovery request within interface-manager and redirects the call
+ * to the respective handler if found.
+ *
+ * @param entityType The type of service recovery. eg :SERVICE or INSTANCE.
+ * @param entityName The type entity for which recovery has to be started. eg : INTERFACE or DPN.
+ * @param entityId The unique id to represent the entity to be recovered
+ */
+ private void recoverService(Class<? extends EntityTypeBase> entityType,
+ Class<? extends EntityNameBase> entityName, String entityId) {
+ String serviceRegistryKey = entityName.toString();
+ serviceRecoveryRegistry.getRegisteredServiceRecoveryHandler(serviceRegistryKey).recoverService(entityId);
}
@Override
+ @Deprecated
public void remove(InstanceIdentifier<Operations> instanceIdentifier, Operations removedDataObject) {
+ // FIXME: this should be doing something, right?
}
@Override
+ @Deprecated
public void update(InstanceIdentifier<Operations> instanceIdentifier,
Operations originalDataObject, Operations updatedDataObject) {
add(instanceIdentifier, updatedDataObject);
+++ /dev/null
-/*
- * Copyright (c) 2018 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.serviceutils.srm.impl;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.EntityNameBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.EntityTypeBase;
-
-@Singleton
-public final class ServiceRecoveryManager {
-
- private final ServiceRecoveryRegistryImpl serviceRecoveryRegistry;
-
- @Inject
- public ServiceRecoveryManager(ServiceRecoveryRegistryImpl serviceRecoveryRegistry) {
- this.serviceRecoveryRegistry = serviceRecoveryRegistry;
- }
-
- private static String getServiceRegistryKey(Class<? extends EntityNameBase> entityName) {
- return entityName.toString();
- }
-
- /**
- * Initiates recovery mechanism for a particular interface-manager entity.
- * This method tries to check whether there is a registered handler for the incoming
- * service recovery request within interface-manager and redirects the call
- * to the respective handler if found.
- * @param entityType
- * The type of service recovery. eg :SERVICE or INSTANCE.
- * @param entityName
- * The type entity for which recovery has to be started. eg : INTERFACE or DPN.
- * @param entityId
- * The unique id to represent the entity to be recovered
- */
- public void recoverService(Class<? extends EntityTypeBase> entityType,
- Class<? extends EntityNameBase> entityName, String entityId) {
- String serviceRegistryKey = getServiceRegistryKey(entityName);
- serviceRecoveryRegistry.getRegisteredServiceRecoveryHandler(serviceRegistryKey).recoverService(entityId);
- }
-}
import java.util.Queue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
+import javax.inject.Inject;
import javax.inject.Singleton;
-import org.apache.aries.blueprint.annotation.service.Service;
import org.opendaylight.serviceutils.srm.RecoverableListener;
import org.opendaylight.serviceutils.srm.ServiceRecoveryInterface;
import org.opendaylight.serviceutils.srm.ServiceRecoveryRegistry;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.RequireServiceComponentRuntime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
-@Service(classes = ServiceRecoveryRegistry.class)
-public class ServiceRecoveryRegistryImpl implements ServiceRecoveryRegistry {
-
+@Component(immediate = true)
+@RequireServiceComponentRuntime
+public final class ServiceRecoveryRegistryImpl implements ServiceRecoveryRegistry {
private static final Logger LOG = LoggerFactory.getLogger(ServiceRecoveryRegistryImpl.class);
private final Map<String, ServiceRecoveryInterface> serviceRecoveryRegistry = new ConcurrentHashMap<>();
private final Map<String, Queue<RecoverableListener>> recoverableListenersMap =
new ConcurrentHashMap<>();
+ @Inject
+ @Activate
+ public ServiceRecoveryRegistryImpl() {
+ // Exposed for DI
+ }
+
@Override
- public void registerServiceRecoveryRegistry(String entityName,
- ServiceRecoveryInterface serviceRecoveryHandler) {
+ public void registerServiceRecoveryRegistry(String entityName, ServiceRecoveryInterface serviceRecoveryHandler) {
serviceRecoveryRegistry.put(entityName, serviceRecoveryHandler);
LOG.trace("Registered service recovery handler for {}", entityName);
}
@Override
public void removeRecoverableListener(String serviceName, RecoverableListener recoverableListener) {
- if (recoverableListenersMap.get(serviceName) != null) {
- recoverableListenersMap.get(serviceName).remove(recoverableListener);
+ Queue<RecoverableListener> queue = getRecoverableListeners(serviceName);
+ if (queue != null) {
+ queue.remove(recoverableListener);
}
}
return recoverableListenersMap.get(serviceName);
}
- ServiceRecoveryInterface getRegisteredServiceRecoveryHandler(String entityName) {
+ @Override
+ public ServiceRecoveryInterface getRegisteredServiceRecoveryHandler(String entityName) {
return serviceRecoveryRegistry.get(entityName);
}
}
package org.opendaylight.serviceutils.srm.impl;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.serviceutils.tools.rpc.FutureRpcResults;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.OdlSrmRpcsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallOutput;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.RequireServiceComponentRuntime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
-public class SrmRpcProvider implements OdlSrmRpcsService {
+@Component(immediate = true, service = OdlSrmRpcsService.class)
+@RequireServiceComponentRuntime
+public final class SrmRpcProvider implements OdlSrmRpcsService, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(SrmRpcProvider.class);
+
private final DataBroker dataBroker;
+ private final Registration reg;
@Inject
- public SrmRpcProvider(DataBroker dataBroker) {
+ @Activate
+ public SrmRpcProvider(@Reference DataBroker dataBroker, @Reference RpcProviderService rpcProvider) {
this.dataBroker = dataBroker;
+ reg = rpcProvider.registerRpcImplementation(OdlSrmRpcsService.class, this);
+ }
+
+ @Override
+ @Deactivate
+ @PreDestroy
+ public void close() {
+ reg.close();
}
@Override
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright © 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <reference id="dataBroker"
- interface="org.opendaylight.mdsal.binding.api.DataBroker" />
-
- <odl:rpc-implementation ref="srmRpcProvider" />
-
-</blueprint>
<relativePath>../../commons/quality-parent</relativePath>
</parent>
- <groupId>org.opendaylight.serviceutils</groupId>
<artifactId>srm-shell</artifactId>
- <version>0.9.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<!-- <name> formatting is used by autorelease to parse and notify projects on
build failure. Please do not modify this unless you have a good reason. -->
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.serviceutils.srm.shell;
import java.util.concurrent.Future;
@Command(scope = "srm", name = "recover", description = "Recover service or instance")
public class RecoverCommand extends OsgiCommandSupport {
-
private static final Logger LOG = LoggerFactory.getLogger(RecoverCommand.class);
- private final OdlSrmRpcsService srmRpcService;
-
- public RecoverCommand(OdlSrmRpcsService srmRpcService) {
- this.srmRpcService = srmRpcService;
- }
-
@Argument(index = 0, name = "type", description = "EntityType, required", required = false, multiValued = false)
String type;
-
@Argument(index = 1, name = "name", description = "EntityName, required", required = false, multiValued = false)
String name;
-
@Argument(index = 2, name = "id", description = "EntityId, optional", required = false, multiValued = false)
String id;
+ private final OdlSrmRpcsService srmRpcService;
+
+ public RecoverCommand(OdlSrmRpcsService srmRpcService) {
+ this.srmRpcService = srmRpcService;
+ }
@Override
+ @Deprecated
protected @Nullable Object doExecute() throws Exception {
RecoverInput input = getInput();
if (input == null) {
}
return inputBuilder.build();
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.serviceutils.srm.shell;
import java.util.concurrent.Future;
@Command(scope = "srm", name = "reinstall", description = "Reinstall service or instance")
public class ReinstallCommand extends OsgiCommandSupport {
-
private static final Logger LOG = LoggerFactory.getLogger(ReinstallCommand.class);
+ @Argument(index = 0, name = "name", description = "EntityName of type service, required",
+ required = false, multiValued = false)
+ String name;
+
private final OdlSrmRpcsService srmRpcService;
private final Class<? extends EntityTypeBase> entityType = EntityTypeService.class;
this.srmRpcService = srmRpcService;
}
- @Argument(index = 0, name = "name", description = "EntityName of type service, required",
- required = false, multiValued = false)
- String name;
-
@Override
+ @Deprecated
protected @Nullable Object doExecute() throws Exception {
ReinstallInput input = getInput();
if (input == null) {
inputBuilder.setEntityName(entityName);
return inputBuilder.build();
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.serviceutils.srm.shell;
import org.apache.karaf.shell.commands.Command;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.ServiceOps;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
@Command(scope = "srm", name = "debug", description = "SRM debug commands")
public class SrmDebugCommand extends OsgiCommandSupport {
-
- private static final Logger LOG = LoggerFactory.getLogger(SrmDebugCommand.class);
-
+ @Option(name = "-c", aliases = {"--clear-ops"}, description = "Clear operations DS",
+ required = true, multiValued = false)
+ boolean clearOps;
private final DataBroker txDataBroker;
public SrmDebugCommand(DataBroker dataBroker) {
- this.txDataBroker = dataBroker;
+ txDataBroker = dataBroker;
}
- @Option(name = "-c", aliases = {"--clear-ops"}, description = "Clear operations DS",
- required = true, multiValued = false)
- boolean clearOps;
-
@Override
+ @Deprecated
protected @Nullable Object doExecute() throws Exception {
if (clearOps) {
clearOpsDs();
* and is available at http://www.eclipse.org/legal/epl-v10.html
-->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<reference id="dataBroker"
interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
-
- <odl:rpc-service id="srmRpcService"
- interface="org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.OdlSrmRpcsService" />
+ <reference id="srmRpcService"
+ interface="org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.OdlSrmRpcsService"/>
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
<command>
<action class="org.opendaylight.serviceutils.srm.shell.RecoverCommand">
- <argument ref="srmRpcService" />
+ <argument ref="srmRpcService"/>
</action>
</command>
<command>
<action class="org.opendaylight.serviceutils.srm.shell.ReinstallCommand">
- <argument ref="srmRpcService" />
+ <argument ref="srmRpcService"/>
</action>
</command>
<command>