use of org.opendaylight.controller.config.util.capability.Capability in project controller by opendaylight.
the class ConfigPusherImplTest method testSuccessConflictingVersionException.
@Test
public void testSuccessConflictingVersionException() throws Exception {
doReturn(new TreeSet<>(Lists.newArrayList("namespace?module=module&revision=2012-12-12"))).when(mockedConfigSnapshot).getCapabilities();
final Capability cap = mock(Capability.class);
doReturn("namespace?module=module&revision=2012-12-12").when(cap).getCapabilityUri();
doReturn(Sets.newHashSet(cap)).when(facadeFactory).getCurrentCapabilities();
final ConfigExecution cfgExec = mock(ConfigExecution.class);
doReturn("cfg exec").when(cfgExec).toString();
doReturn(cfgExec).when(facade).getConfigExecution(any(Config.class), any(Element.class));
doNothing().when(facade).executeConfigExecution(any(ConfigExecution.class));
doThrow(ConflictingVersionException.class).doThrow(ConflictingVersionException.class).doReturn(mock(CommitStatus.class)).when(facade).commitSilentTransaction();
doReturn(Sets.newHashSet(module)).when(yangStoreService).getModules();
final ConfigPusherImpl configPusher = new ConfigPusherImpl(facadeFactory, 5000, 5000);
configPusher.pushConfigs(Collections.singletonList(mockedConfigSnapshot));
configPusher.processSingle(Lists.<AutoCloseable>newArrayList(), mBeanServer, mockedAggregator, true);
verify(facade, times(3)).executeConfigExecution(cfgExec);
verify(facade, times(3)).commitSilentTransaction();
}
use of org.opendaylight.controller.config.util.capability.Capability in project controller by opendaylight.
the class ConfigPusherImplTest method testPersisterSuccessfulPush.
@Test
public void testPersisterSuccessfulPush() throws Exception {
doReturn(new TreeSet<>(Lists.newArrayList("namespace?module=module&revision=2012-12-12"))).when(mockedConfigSnapshot).getCapabilities();
final Capability cap = mock(Capability.class);
doReturn("namespace?module=module&revision=2012-12-12").when(cap).getCapabilityUri();
doReturn(Sets.newHashSet(cap)).when(facadeFactory).getCurrentCapabilities();
final ConfigExecution cfgExec = mock(ConfigExecution.class);
doReturn("cfg exec").when(cfgExec).toString();
doReturn(cfgExec).when(facade).getConfigExecution(any(Config.class), any(Element.class));
doNothing().when(facade).executeConfigExecution(any(ConfigExecution.class));
doReturn(mock(CommitStatus.class)).when(facade).commitSilentTransaction();
doReturn(Sets.newHashSet(module)).when(yangStoreService).getModules();
final ConfigPusherImpl configPusher = new ConfigPusherImpl(facadeFactory, 0, 0);
configPusher.pushConfigs(Collections.singletonList(mockedConfigSnapshot));
configPusher.processSingle(Lists.<AutoCloseable>newArrayList(), mBeanServer, mockedAggregator, true);
verify(facade).executeConfigExecution(cfgExec);
verify(facade).commitSilentTransaction();
}
use of org.opendaylight.controller.config.util.capability.Capability in project controller by opendaylight.
the class YangStoreService method notifyListeners.
void notifyListeners(final YangStoreSnapshot previous, final YangStoreSnapshot current) {
final Set<Module> prevModules = previous.getModules();
final Set<Module> currModules = current.getModules();
final Set<Module> removed = Sets.difference(prevModules, currModules);
final Set<Module> added = Sets.difference(currModules, prevModules);
final Set<Capability> addedCaps = toCapabilities(added, current);
final Set<Capability> removedCaps = toCapabilities(removed, current);
synchronized (this.listeners) {
for (final ModuleListener listener : this.listeners) {
listener.onCapabilitiesChanged(addedCaps, removedCaps);
}
}
}
use of org.opendaylight.controller.config.util.capability.Capability in project controller by opendaylight.
the class ConfigPersisterNotificationListener method handleAfterCommitNotification.
private void handleAfterCommitNotification() {
try {
final Set<Capability> currentCapabilities = facade.getCurrentCapabilities();
final Element configSnapshot = facade.createFacade("config-persister").getConfiguration(XmlUtil.newDocument(), Datastore.running, Optional.<String>absent());
persisterAggregator.persistConfig(new CapabilityStrippingConfigSnapshotHolder(configSnapshot, ConfigPusherImpl.transformCapabilities(currentCapabilities)));
LOG.trace("Configuration persisted successfully");
} catch (final IOException e) {
throw new RuntimeException("Unable to persist configuration snapshot", e);
}
}
use of org.opendaylight.controller.config.util.capability.Capability in project controller by opendaylight.
the class ConfigSubsystemFacadeFactory method getCurrentCapabilities.
public Set<Capability> getCurrentCapabilities() {
Set<Module> modules = yangStoreService.getModules();
final Set<Capability> capabilities = Sets.newHashSet();
for (Module module : modules) {
capabilities.add(new YangModuleCapability(module, yangStoreService.getModuleSource(RevisionSourceIdentifier.create(module.getName(), module.getRevision()))));
}
return capabilities;
}
Aggregations