Search in sources :

Example 1 with ConfigTransactionClient

use of org.opendaylight.controller.config.util.ConfigTransactionClient in project controller by opendaylight.

the class TransactionProvider method abortTransaction.

public synchronized void abortTransaction() {
    LOG.debug("Aborting current transaction");
    Optional<ObjectName> taON = getTransaction();
    Preconditions.checkState(taON.isPresent(), NO_TRANSACTION_FOUND_FOR_SESSION + sessionIdForReporting);
    ConfigTransactionClient transactionClient = configRegistryClient.getConfigTransactionClient(taON.get());
    transactionClient.abortConfig();
    allOpenedTransactions.remove(candidateTx);
    candidateTx = null;
}
Also used : ConfigTransactionClient(org.opendaylight.controller.config.util.ConfigTransactionClient) ObjectName(javax.management.ObjectName)

Example 2 with ConfigTransactionClient

use of org.opendaylight.controller.config.util.ConfigTransactionClient in project controller by opendaylight.

the class TransactionProvider method closeReadTransaction.

public synchronized void closeReadTransaction() {
    LOG.debug("Closing read transaction");
    Optional<ObjectName> taON = getReadTransaction();
    Preconditions.checkState(taON.isPresent(), NO_TRANSACTION_FOUND_FOR_SESSION + sessionIdForReporting);
    ConfigTransactionClient transactionClient = configRegistryClient.getConfigTransactionClient(taON.get());
    transactionClient.abortConfig();
    allOpenedTransactions.remove(readTx);
    readTx = null;
}
Also used : ConfigTransactionClient(org.opendaylight.controller.config.util.ConfigTransactionClient) ObjectName(javax.management.ObjectName)

Example 3 with ConfigTransactionClient

use of org.opendaylight.controller.config.util.ConfigTransactionClient in project controller by opendaylight.

the class TransactionProvider method validateTransaction.

public void validateTransaction() throws ValidationException {
    Optional<ObjectName> taON = getTransaction();
    Preconditions.checkState(taON.isPresent(), NO_TRANSACTION_FOUND_FOR_SESSION + sessionIdForReporting);
    ConfigTransactionClient transactionClient = configRegistryClient.getConfigTransactionClient(taON.get());
    transactionClient.validateConfig();
}
Also used : ConfigTransactionClient(org.opendaylight.controller.config.util.ConfigTransactionClient) ObjectName(javax.management.ObjectName)

Example 4 with ConfigTransactionClient

use of org.opendaylight.controller.config.util.ConfigTransactionClient in project controller by opendaylight.

the class SimpleConfigurationTest method testValidationUsingJMXClient.

@Test
public void testValidationUsingJMXClient() throws Exception {
    ConfigTransactionClient transaction = configRegistryClient.createTransaction();
    testValidation(transaction);
}
Also used : ConfigTransactionClient(org.opendaylight.controller.config.util.ConfigTransactionClient) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest) Test(org.junit.Test)

Example 5 with ConfigTransactionClient

use of org.opendaylight.controller.config.util.ConfigTransactionClient in project controller by opendaylight.

the class ConfigSubsystemFacade method getConfiguration.

public Element getConfiguration(final Document document, final Datastore source, final Optional<String> maybeNamespace) {
    final ConfigTransactionClient registryClient;
    // in case of candidate, get current transaction representing candidate
    if (source == Datastore.running) {
        final ObjectName readTx = transactionProvider.getOrCreateReadTransaction();
        registryClient = configRegistryClient.getConfigTransactionClient(readTx);
    } else {
        registryClient = configRegistryClient.getConfigTransactionClient(transactionProvider.getOrCreateTransaction());
    }
    try {
        Element dataElement = XmlUtil.createElement(document, XmlMappingConstants.DATA_KEY, Optional.<String>absent());
        final Set<ObjectName> instances = Datastore.getInstanceQueryStrategy(source, this.transactionProvider).queryInstances(configRegistryClient);
        final Config configMapping = new Config(transformMbeToModuleConfigs(yangStoreService.getModuleMXBeanEntryMap()), yangStoreService.getEnumResolver());
        ServiceRegistryWrapper serviceTracker = new ServiceRegistryWrapper(registryClient);
        dataElement = configMapping.toXml(instances, maybeNamespace, document, dataElement, serviceTracker);
        return dataElement;
    } finally {
        if (source == Datastore.running) {
            transactionProvider.closeReadTransaction();
        }
    }
}
Also used : ModuleConfig(org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig) Config(org.opendaylight.controller.config.facade.xml.mapping.config.Config) InstanceConfig(org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfig) Element(org.w3c.dom.Element) XmlElement(org.opendaylight.controller.config.util.xml.XmlElement) ConfigTransactionClient(org.opendaylight.controller.config.util.ConfigTransactionClient) ServiceRegistryWrapper(org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper) ObjectName(javax.management.ObjectName)

Aggregations

ConfigTransactionClient (org.opendaylight.controller.config.util.ConfigTransactionClient)13 ObjectName (javax.management.ObjectName)10 HashMap (java.util.HashMap)1 Map (java.util.Map)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 Test (org.junit.Test)1 Config (org.opendaylight.controller.config.facade.xml.mapping.config.Config)1 InstanceConfig (org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfig)1 ModuleConfig (org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig)1 ServiceRegistryWrapper (org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper)1 YangStoreContext (org.opendaylight.controller.config.facade.xml.osgi.YangStoreContext)1 InstanceRuntime (org.opendaylight.controller.config.facade.xml.runtime.InstanceRuntime)1 ModuleRuntime (org.opendaylight.controller.config.facade.xml.runtime.ModuleRuntime)1 Runtime (org.opendaylight.controller.config.facade.xml.runtime.Runtime)1 AbstractConfigTest (org.opendaylight.controller.config.manager.impl.AbstractConfigTest)1 XmlElement (org.opendaylight.controller.config.util.xml.XmlElement)1 Element (org.w3c.dom.Element)1