use of org.opendaylight.yangtools.concepts.AbstractRegistration in project bgpcep by opendaylight.
the class ConfigLoaderImpl method registerConfigFile.
@Override
public synchronized AbstractRegistration registerConfigFile(final ConfigFileProcessor config) {
final String pattern = INITIAL + config.getSchemaPath().getLastComponent().getLocalName() + EXTENSION;
this.configServices.put(pattern, config);
final File[] fList = this.file.listFiles();
final List<String> newFiles = new ArrayList<>();
if (fList != null) {
for (final File newFile : fList) {
if (newFile.isFile()) {
final String filename = newFile.getName();
if (Pattern.matches(pattern, filename)) {
newFiles.add(filename);
}
}
}
}
for (final String filename : newFiles) {
handleConfigFile(config, filename);
}
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (ConfigLoaderImpl.this) {
ConfigLoaderImpl.this.configServices.remove(pattern);
}
}
};
}
use of org.opendaylight.yangtools.concepts.AbstractRegistration in project bgpcep by opendaylight.
the class ConfigLoaderImplTest method configLoaderImplTest.
@Test
public void configLoaderImplTest() {
assertNotNull(ClassLoader.getSystemClassLoader().getResource("etc/opendaylight/bgpcep/protocols-config.xml"));
final AbstractRegistration ticket = this.configLoader.registerConfigFile(this.processor);
verify(this.processor).loadConfiguration(any());
triggerEvent("protocols-config.xml");
verify(this.processor, timeout(20000).times(2)).loadConfiguration(any());
ticket.close();
triggerEvent("protocols-config.xml");
verify(this.processor, timeout(20000).times(2)).loadConfiguration(any());
}
use of org.opendaylight.yangtools.concepts.AbstractRegistration in project bgpcep by opendaylight.
the class ActionsRegistryImpl method registerActionPolicy.
AbstractRegistration registerActionPolicy(final Class<? extends Augmentation<Actions>> actionPolicyClass, final ActionsAugPolicy actionPolicy) {
synchronized (this.actionsRegistry) {
final ActionsAugPolicy prev = this.actionsRegistry.putIfAbsent(actionPolicyClass, actionPolicy);
Preconditions.checkState(prev == null, "Action Policy %s already registered %s", actionPolicyClass, prev);
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (ActionsRegistryImpl.this.actionsRegistry) {
ActionsRegistryImpl.this.actionsRegistry.remove(actionPolicyClass);
}
}
};
}
}
use of org.opendaylight.yangtools.concepts.AbstractRegistration in project bgpcep by opendaylight.
the class ActionsRegistryImpl method registerBgpActionPolicy.
public AbstractRegistration registerBgpActionPolicy(final Class<? extends ChildOf<BgpActions>> bgpActionPolicyClass, final BgpActionPolicy bgpActionPolicy) {
synchronized (this.bgpActions) {
final BgpActionPolicy prev = this.bgpActions.putIfAbsent(bgpActionPolicyClass, bgpActionPolicy);
Preconditions.checkState(prev == null, "Action Policy %s already registered %s", bgpActionPolicyClass, prev);
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (ActionsRegistryImpl.this.bgpActions) {
ActionsRegistryImpl.this.bgpActions.remove(bgpActionPolicyClass);
}
}
};
}
}
use of org.opendaylight.yangtools.concepts.AbstractRegistration in project bgpcep by opendaylight.
the class BgpTopologyDeployerImpl method registerService.
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public AbstractRegistration registerService(final TopologyReferenceSingletonService topologyProviderService) {
final Dictionary<String, String> properties = new Hashtable<>();
properties.put("topology-id", topologyProviderService.getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId().getValue());
final ServiceRegistration<?> registerService = this.context.registerService(new String[] { TopologyReference.class.getName() }, topologyProviderService, properties);
final ClusterSingletonServiceRegistration registerClusterSingletonService = registerSingletonService(topologyProviderService);
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
try {
registerClusterSingletonService.close();
} catch (final Exception e) {
LOG.warn("Failed to close ClusterSingletonServiceRegistration {} for TopologyBuilder {}", registerClusterSingletonService, topologyProviderService.getInstanceIdentifier(), e);
} finally {
registerService.unregister();
}
}
};
}
Aggregations