当前位置: 首页>>代码示例>>Java>>正文


Java ValidationException类代码示例

本文整理汇总了Java中org.opendaylight.controller.config.api.ValidationException的典型用法代码示例。如果您正苦于以下问题:Java ValidationException类的具体用法?Java ValidationException怎么用?Java ValidationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ValidationException类属于org.opendaylight.controller.config.api包,在下文中一共展示了ValidationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateNoLocks

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@SuppressWarnings("IllegalCatch")
private void validateNoLocks() throws ValidationException {
    transactionStatus.checkNotAborted();
    LOG.trace("Validating transaction {}", getTransactionIdentifier());
    // call validate()
    List<ValidationException> collectedExceptions = new ArrayList<>();
    for (Entry<ModuleIdentifier, Module> entry : dependencyResolverManager.getAllModules().entrySet()) {
        ModuleIdentifier name = entry.getKey();
        Module module = entry.getValue();
        try {
            module.validate();
        } catch (final Exception e) {
            LOG.warn("Validation exception in {}", getTransactionName(), e);
            collectedExceptions.add(ValidationException.createForSingleException(name, e));
        }
    }
    if (!collectedExceptions.isEmpty()) {
        throw ValidationException.createFromCollectedValidationExceptions(collectedExceptions);
    }
    LOG.trace("Validated transaction {}", getTransactionIdentifier());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:22,代码来源:ConfigTransactionControllerImpl.java

示例2: validateBeforeCommitAndLockTransaction

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
/**
 * If this method passes validation, it will grab
 * {@link TransactionStatus#secondPhaseCommitStarted} lock. This lock will
 * prevent calling @{link #validateBeforeCommitAndLockTransaction}, effectively
 * only allowing to call {@link #secondPhaseCommit} after successful return of
 * this method.
 */
@Override
public synchronized CommitInfo validateBeforeCommitAndLockTransaction() throws ValidationException {
    transactionStatus.checkNotAborted();
    transactionStatus.checkNotCommitStarted();
    configBeanModificationDisabled.set(true);
    try {
        validateNoLocks();
    } catch (final ValidationException e) {
        LOG.trace("Commit failed on validation");
        // recoverable error
        configBeanModificationDisabled.set(false);
        throw e;
    }
    // errors in this state are not recoverable. modules are not mutable
    // anymore.
    transactionStatus.setSecondPhaseCommitStarted();
    return dependencyResolverManager.toCommitInfo();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:26,代码来源:ConfigTransactionControllerImpl.java

示例3: testInstanceAlreadyExistsException

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@Test
public void testInstanceAlreadyExistsException()
        throws ConflictingVersionException, ValidationException,
        InstanceAlreadyExistsException {
    ConfigTransactionJMXClient transaction = configRegistryClient
            .createTransaction();

    createModule(transaction, instanceName);
    transaction.commit();

    transaction = configRegistryClient.createTransaction();
    try {
        createModule(transaction, instanceName);
        fail();
    } catch (InstanceAlreadyExistsException e) {

    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:ITTest.java

示例4: testReusingOldInstance

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@Test
public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,
        ValidationException {

    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    createInstance(transaction, instanceName);

    transaction.commit();

    transaction = configRegistryClient.createTransaction();
    assertBeanCount(1, factory.getImplementationName());
    CommitStatus status = transaction.commit();

    assertBeanCount(1, factory.getImplementationName());
    assertStatus(status, 0, 0, 1);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:GlobalEventExecutorModuleTest.java

示例5: executeWithMissingModuleFactoryRetries

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
private void executeWithMissingModuleFactoryRetries(final ConfigSubsystemFacade facade, final ConfigExecution configExecution)
        throws DocumentedException, ValidationException, ModuleFactoryNotFoundException {
    Stopwatch stopwatch = Stopwatch.createStarted();
    ModuleFactoryNotFoundException lastException = null;
    do {
        try {
            facade.executeConfigExecution(configExecution);
            return;
        } catch (final ModuleFactoryNotFoundException e) {
            LOG.debug("{} - will retry after timeout", e.toString());
            lastException = e;
            sleep();
        }
    } while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < maxWaitForCapabilitiesMillis);

    throw lastException;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:ConfigPusherImpl.java

示例6: testReconfigure

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@Test
public void testReconfigure() throws InstanceAlreadyExistsException, ConflictingVersionException,
        ValidationException, InstanceNotFoundException {

    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    createInstance(transaction, instanceName, null);

    transaction.commit();

    transaction = configRegistryClient.createTransaction();
    assertBeanCount(1, factory.getImplementationName());
    NettyThreadgroupModuleMXBean mxBean = transaction.newMBeanProxy(
            transaction.lookupConfigBean(AbstractNettyThreadgroupModuleFactory.NAME, instanceName),
            NettyThreadgroupModuleMXBean.class);
    mxBean.setThreadCount(1);
    CommitStatus status = transaction.commit();

    assertBeanCount(1, factory.getImplementationName());
    assertStatus(status, 0, 1, 0);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:NettyThreadgroupModuleTest.java

示例7: testDestroyModuleDependency

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@Test
public void testDestroyModuleDependency() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName r1 = transaction.createModule(factory.getImplementationName(), "root1");
    ObjectName m1 = transaction.createModule(factory.getImplementationName(), "middle1");

    MultipleDependenciesModuleMXBean r1Proxy = transaction.newMXBeanProxy(r1, MultipleDependenciesModuleMXBean.class);
    r1Proxy.setSingle(m1);
    transaction.commit();

    transaction = configRegistryClient.createTransaction();
    transaction.destroyModule(factory.getImplementationName(), "middle1");
    try {
        transaction.commit();
        fail("Validation exception expected");
    } catch (ValidationException e) {
        assertThat(e.getFailedValidations().keySet(), CoreMatchers.hasItem("multiple-dependencies"));
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:MultipleDependenciesModuleTest.java

示例8: test

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
private void test(final ConfigExecution execution, final EditStrategyType editStrategyType)
        throws ValidationException, DocumentedException {
    ObjectName taON = transactionProvider.getTestTransaction();
    try {
        // default strategy = replace wipes config
        if (editStrategyType == EditStrategyType.replace) {
            transactionProvider.wipeTestTransaction(taON);
        }

        ConfigTransactionClient ta = configRegistryClient.getConfigTransactionClient(taON);

        handleMisssingInstancesOnTransaction(ta, execution);
        setServicesOnTransaction(ta, execution);
        setOnTransaction(ta, execution);
        transactionProvider.validateTestTransaction(taON);
    } finally {
        transactionProvider.abortTestTransaction(taON);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:ConfigSubsystemFacade.java

示例9: invoke

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@SuppressWarnings("IllegalCatch")
@Override
public Object invoke(final String actionName, final Object[] params, final String[] signature)
        throws MBeanException, ReflectionException {
    if ("validate".equals(actionName) && (params == null || params.length == 0)
            && (signature == null || signature.length == 0)) {
        try {
            validate();
        } catch (final Exception e) {
            throw new MBeanException(ValidationException.createForSingleException(moduleIdentifier, e));
        }
        return Void.TYPE;
    }
    return super.invoke(actionName, params, signature);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:16,代码来源:DynamicWritableWrapper.java

示例10: commitConfig

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@Override
public CommitStatus commitConfig(final ObjectName transactionControllerON)
        throws ConflictingVersionException, ValidationException {
    final CommitStatus commitStatus = delegate.commitConfig(transactionControllerON);
    notifier.notifyCommit(ObjectNameUtil.getTransactionName(transactionControllerON));
    return commitStatus;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:JMXNotifierConfigRegistry.java

示例11: validateConfig

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@Override
public synchronized void validateConfig() throws ValidationException {
    if (configBeanModificationDisabled.get()) {
        throw new IllegalStateException("Cannot start validation");
    }
    configBeanModificationDisabled.set(true);
    try {
        validateNoLocks();
    } finally {
        configBeanModificationDisabled.set(false);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:13,代码来源:ConfigTransactionControllerImpl.java

示例12: commitConfig

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@Override
public CommitStatus commitConfig(final ObjectName transactionControllerON)
        throws ValidationException, ConflictingVersionException {
    if (NOOP_TX_NAME.equals(transactionControllerON) || closed.get()) {
        return new CommitStatus(Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
    }

    configTransactionLock.lock();
    try {
        return commitConfigSafe(transactionControllerON);
    } finally {
        configTransactionLock.unlock();
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:15,代码来源:ConfigRegistryImpl.java

示例13: commitConfigSafe

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@GuardedBy("configTransactionLock")
private CommitStatus commitConfigSafe(final ObjectName transactionControllerON)
        throws ConflictingVersionException, ValidationException {
    final String transactionName = ObjectNameUtil.getTransactionName(transactionControllerON);
    LOG.trace("About to commit {}. Current parentVersion: {}, versionCounter {}", transactionName, version,
            versionCounter);

    // find ConfigTransactionController
    Map<String, Entry<ConfigTransactionControllerInternal, ConfigTransactionLookupRegistry>> transactions =
            transactionsHolder.getCurrentTransactions();
    Entry<ConfigTransactionControllerInternal, ConfigTransactionLookupRegistry> configTransactionControllerEntry =
            transactions.get(transactionName);
    if (configTransactionControllerEntry == null) {
        throw new IllegalArgumentException(String.format("Transaction with name '%s' not found", transactionName));
    }
    ConfigTransactionControllerInternal configTransactionController = configTransactionControllerEntry.getKey();
    // check optimistic lock
    if (version != configTransactionController.getParentVersion()) {
        throw new ConflictingVersionException(
                String.format("Optimistic lock failed. Expected parent version %d, was %d", version,
                        configTransactionController.getParentVersion()));
    }
    // optimistic lock ok

    CommitInfo commitInfo = configTransactionController.validateBeforeCommitAndLockTransaction();
    lastListOfFactories = Collections
            .unmodifiableList(configTransactionController.getCurrentlyRegisteredFactories());
    return secondPhaseCommit(configTransactionController, commitInfo, configTransactionControllerEntry.getValue());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:30,代码来源:ConfigRegistryImpl.java

示例14: testWithAPSP_useScheduledNames

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
@Test
public void testWithAPSP_useScheduledNames() throws InstanceAlreadyExistsException, ValidationException {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName scheduledName = transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);

    ObjectName apspName = transaction.createModule(TestingParallelAPSPModuleFactory.NAME, "apsp1");
    TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(apspName,
            TestingParallelAPSPConfigMXBean.class);
    apspProxy.setThreadPool(scheduledName);
    apspProxy.setSomeParam("someParam");
    transaction.validateConfig();

}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:TwoInterfacesExportTest.java

示例15: createScheduled

import org.opendaylight.controller.config.api.ValidationException; //导入依赖的package包/类
private ObjectName createScheduled()
        throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();

    // create using TestingThreadPoolIfc:
    ObjectName createdConfigBean = transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME,
            SCHEDULED1);
    // commit
    transaction.commit();
    return createdConfigBean;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:12,代码来源:RuntimeBeanTest.java


注:本文中的org.opendaylight.controller.config.api.ValidationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。