/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. 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,
import org.slf4j.LoggerFactory;
/**
- * Every time factory is added or removed, blank transaction is triggered to handle
- * {@link org.opendaylight.controller.config.spi.ModuleFactory#getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory, org.osgi.framework.BundleContext)}
- * functionality.
+ * Every time factory is added or removed, blank transaction is triggered to
+ * handle.
*/
public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<ModuleFactory, Object> {
private static final Logger LOG = LoggerFactory.getLogger(BlankTransactionServiceTracker.class);
this(() -> {
ObjectName tx = configRegistry.beginConfig(true);
return configRegistry.commitConfig(tx);
- });
+ });
}
public BlankTransactionServiceTracker(final BlankTransaction blankTransaction) {
- this(blankTransaction, DEFAULT_MAX_ATTEMPTS, Executors.newSingleThreadExecutor(new ThreadFactoryBuilder()
- .setNameFormat("config-blank-txn-%d").build()));
+ this(blankTransaction, DEFAULT_MAX_ATTEMPTS, Executors
+ .newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("config-blank-txn-%d").build()));
}
@VisibleForTesting
}
@Override
- public Object addingService(ServiceReference<ModuleFactory> moduleFactoryServiceReference) {
+ public Object addingService(final ServiceReference<ModuleFactory> moduleFactoryServiceReference) {
blankTransactionAsync();
return null;
}
}
void blankTransactionSync() {
- // race condition check: config-persister might push new configuration while server is starting up.
+ // race condition check: config-persister might push new configuration while
+ // server is starting up.
ConflictingVersionException lastException = null;
for (int i = 0; i < maxAttempts; i++) {
try {
CommitStatus commitStatus = blankTransaction.hit();
LOG.debug("Committed blank transaction with status {}", commitStatus);
return;
- } catch (ConflictingVersionException e) {
+ } catch (final ConflictingVersionException e) {
lastException = e;
try {
Thread.sleep(1000);
- } catch (InterruptedException interruptedException) {
+ } catch (final InterruptedException interruptedException) {
Thread.currentThread().interrupt();
LOG.debug("blankTransactionSync was interrupted");
return;
}
- } catch (ValidationException e) {
+ } catch (final ValidationException e) {
LOG.error("Validation exception while running blank transaction indicates programming error", e);
}
}
}
@Override
- public void modifiedService(ServiceReference <ModuleFactory> moduleFactoryServiceReference, Object o) {
+ public void modifiedService(final ServiceReference<ModuleFactory> moduleFactoryServiceReference,
+ final Object object) {
blankTransactionAsync();
}
@Override
- public void removedService(ServiceReference<ModuleFactory> moduleFactoryServiceReference, Object o) {
+ public void removedService(final ServiceReference<ModuleFactory> moduleFactoryServiceReference,
+ final Object object) {
blankTransactionAsync();
}