本文整理汇总了Java中org.opendaylight.yangtools.yang.common.RpcResult类的典型用法代码示例。如果您正苦于以下问题:Java RpcResult类的具体用法?Java RpcResult怎么用?Java RpcResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RpcResult类属于org.opendaylight.yangtools.yang.common包,在下文中一共展示了RpcResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRPC
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Test
public void testRPC() throws InterruptedException, ExecutionException {
String name = "Ed Warnicke";
HelloService service = getSession().getRpcService(HelloService.class);
HelloWorldInput input = new HelloWorldInputBuilder()
.setName(name)
.build();
Future<RpcResult<HelloWorldOutput>> outputFuture = service.helloWorld(input);
RpcResult<HelloWorldOutput> outputResult = outputFuture.get();
Assert.assertTrue("RPC was unsuccessful", outputResult.isSuccessful());
Assert.assertEquals("Did not receive the expected response to helloWorld RPC", "Hello " + name,
outputResult.getResult().getGreeting());
validateRPCResponse(name, outputResult.getResult().getGreeting());
validateGreetingRegistry(name);
}
示例2: shutdownPrefixShardReplica
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
public Future<RpcResult<Void>> shutdownPrefixShardReplica(final ShutdownPrefixShardReplicaInput input) {
LOG.debug("Received shutdown-prefix-shard-replica rpc, input: {}", input);
final InstanceIdentifier<?> shardPrefix = input.getPrefix();
if (shardPrefix == null) {
final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "bad-element",
"A valid shard prefix must be specified");
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(rpcError).build());
}
final YangInstanceIdentifier shardPath = bindingNormalizedNodeSerializer.toYangInstanceIdentifier(shardPrefix);
final String cleanPrefixShardName = ClusterUtils.getCleanShardName(shardPath);
return shutdownShardGracefully(cleanPrefixShardName);
}
示例3: deregisterClient
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
public Future<RpcResult<DeregisterClientOutput>> deregisterClient(DeregisterClientInput input) {
try {
if (connections.remove(input.getClientId().toString()) != null) {
TenantManager.deregisterClient(input.getClientId());
FpcagentDispatcher.removeStrategy(input.getClientId());
clientIdList.remove(input.getClientId());
LOG.info("Connection Removed for Client {}", input.getClientId());
checkPoint();
}
return Futures.immediateFuture(RpcResultBuilder.<DeregisterClientOutput>success().build());
} catch (Exception exc) {
ErrorLog.logError("Error in new Connection Binding" + exc.getMessage(), exc.getStackTrace());
return Futures.immediateFuture(RpcResultBuilder.<DeregisterClientOutput>failed()
.withError(RpcError.ErrorType.APPLICATION,
"Error Occurred During Client Binding",
exc)
.build());
}
}
示例4: subscribeDdtl
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
public Future<RpcResult<Void>> subscribeDdtl() {
if (ddtlReg != null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.",
"There is already dataTreeChangeListener registered on id-ints list.");
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
idIntsDdtl = new IdIntsDOMDataTreeLIstener();
try {
ddtlReg =
domDataTreeService.registerListener(idIntsDdtl,
Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
ProduceTransactionsHandler.ID_INT_YID))
, true, Collections.emptyList());
} catch (DOMDataTreeLoopException e) {
LOG.error("Failed to register DOMDataTreeListener.", e);
}
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
示例5: subscribeDtcl
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
public Future<RpcResult<Void>> subscribeDtcl() {
if (dtclReg != null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.",
"There is already dataTreeChangeListener registered on id-ints list.");
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
idIntsListener = new IdIntsListener();
dtclReg = domDataTreeChangeService
.registerDataTreeChangeListener(
new org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier(
CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID),
idIntsListener);
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
示例6: testSomething
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Test
@Ignore //ignored because it is not a test right now. Illustrative purposes only.
public void testSomething() throws Exception {
MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness(1L)
.setToasterToastType(WheatBread.class).build();
// NOTE: In a real test we would want to override the Thread.sleep() to
// prevent our junit test
// for sleeping for a second...
Future<RpcResult<Void>> makeToast = toaster.makeToast(toastInput);
RpcResult<Void> rpcResult = makeToast.get();
assertNotNull(rpcResult);
assertTrue(rpcResult.isSuccessful());
// etc
}
示例7: subscribeYnl
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
public Future<RpcResult<Void>> subscribeYnl(final SubscribeYnlInput input) {
LOG.debug("subscribe-ynl, input: {}", input);
if (ynlRegistrations.containsKey(input.getId())) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.",
"There is already ynl listener registered for this id: " + input.getId());
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
ynlRegistrations.put(input.getId(),
notificationService.registerNotificationListener(new YnlListener(input.getId())));
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
示例8: testChangeMemberVotingStatesForSingleNodeShard
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Test
public void testChangeMemberVotingStatesForSingleNodeShard() throws Exception {
String name = "testChangeMemberVotingStatesForSingleNodeShard";
String moduleShardsConfig = "module-shards-member1.conf";
MemberNode leaderNode = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name)
.moduleShardsConfig(moduleShardsConfig).datastoreContextBuilder(
DatastoreContext.newBuilder().shardHeartbeatIntervalInMillis(300).shardElectionTimeoutFactor(1))
.build();
leaderNode.configDataStore().waitTillReady();
// Invoke RPC service on member-3 to change voting status
ClusterAdminRpcService service = new ClusterAdminRpcService(leaderNode.configDataStore(),
leaderNode.operDataStore(), null);
RpcResult<Void> rpcResult = service
.changeMemberVotingStatesForShard(new ChangeMemberVotingStatesForShardInputBuilder()
.setShardName("cars").setDataStoreType(DataStoreType.Config)
.setMemberVotingState(ImmutableList
.of(new MemberVotingStateBuilder().setMemberName("member-1").setVoting(FALSE).build()))
.build())
.get(10, TimeUnit.SECONDS);
verifyFailedRpcResult(rpcResult);
verifyVotingStates(leaderNode.configDataStore(), "cars", new SimpleEntry<>("member-1", TRUE));
}
示例9: bindingRpcInvoker_DomRoutedProviderTest
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Test
public void bindingRpcInvoker_DomRoutedProviderTest() throws Exception {
KnockKnockOutputBuilder builder = new KnockKnockOutputBuilder();
builder.setAnswer("open");
final KnockKnockOutput output = builder.build();
provisionRegistry.registerRpcImplementation((rpc, input) -> {
ContainerNode result = testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(output);
return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
}, DOMRpcIdentifier.create(KNOCK_KNOCK_PATH, BI_NODE_C_ID));
OpendaylightOfMigrationTestModelService baKnockInvoker =
providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
Future<RpcResult<KnockKnockOutput>> baResult = baKnockInvoker.knockKnock((knockKnock(BA_NODE_C_ID).setQuestion("Who's there?").build()));
assertNotNull(baResult);
assertEquals(output, baResult.get().getResult());
}
示例10: createTopic
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
public Future<RpcResult<CreateTopicOutput>> createTopic(final CreateTopicInput input) {
LOG.debug("Received Topic creation request: NotificationPattern -> {}, NodeIdPattern -> {}",
input.getNotificationPattern(),
input.getNodeIdPattern());
final NotificationPattern notificationPattern = new NotificationPattern(input.getNotificationPattern());
//FIXME: do not use Util.wildcardToRegex - NodeIdPatter should be regex
final String nodeIdPattern = input.getNodeIdPattern().getValue();
final EventSourceTopic eventSourceTopic = EventSourceTopic.create(notificationPattern, nodeIdPattern, this);
eventSourceTopicMap.put(eventSourceTopic.getTopicId(), eventSourceTopic);
final CreateTopicOutput cto = new CreateTopicOutputBuilder()
.setTopicId(eventSourceTopic.getTopicId())
.build();
LOG.info("Topic has been created: NotificationPattern -> {}, NodeIdPattern -> {}",
input.getNotificationPattern(),
input.getNodeIdPattern());
return Util.resultRpcSuccessFor(cto);
}
示例11: checkPublishNotifications
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
public Future<RpcResult<CheckPublishNotificationsOutput>> checkPublishNotifications(
final CheckPublishNotificationsInput input) {
final PublishNotificationsTask task = publishNotificationsTasks.get(input.getId());
if (task == null) {
return Futures.immediateFuture(RpcResultBuilder.success(
new CheckPublishNotificationsOutputBuilder().setActive(false)).build());
}
final CheckPublishNotificationsOutputBuilder checkPublishNotificationsOutputBuilder =
new CheckPublishNotificationsOutputBuilder().setActive(!task.isFinished());
if (task.getLastError() != null) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
task.getLastError().printStackTrace(pw);
checkPublishNotificationsOutputBuilder.setLastError(task.getLastError().toString() + sw.toString());
}
final CheckPublishNotificationsOutput output =
checkPublishNotificationsOutputBuilder.setPublishCount(task.getCurrentNotif()).build();
return Futures.immediateFuture(RpcResultBuilder.success(output).build());
}
示例12: registerOwnership
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
public Future<RpcResult<Void>> registerOwnership(final RegisterOwnershipInput input) {
if(registeredListener.compareAndSet(false, true)) {
ownershipService.registerListener(ENTITY_TYPE, ownershipListener);
}
Entity entity = new Entity(ENTITY_TYPE, input.getCarId());
try {
ownershipService.registerCandidate(entity);
} catch (CandidateAlreadyRegisteredException e) {
return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION,
"Could not register for car " + input.getCarId(), e).buildFuture();
}
return RpcResultBuilder.<Void>success().buildFuture();
}
示例13: transform
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
private DOMRpcResult transform(final RpcResult<?> input) {
if (input.isSuccessful()) {
final Object inputData = input.getResult();
if (inputData instanceof DataContainer) {
return new DefaultDOMRpcResult(codec.toNormalizedNodeRpcData((DataContainer) inputData));
} else {
return new DefaultDOMRpcResult((NormalizedNode<?, ?>) null);
}
}
return new DefaultDOMRpcResult(input.getErrors());
}
示例14: unregisterCommitCohort
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public Future<RpcResult<Void>> unregisterCommitCohort() {
final DOMDataTreeCommitCohortRegistration<CarEntryDataTreeCommitCohort> reg = commitCohortReg.getAndSet(null);
if (reg != null) {
try {
reg.close();
LOG_CAR_PROVIDER.info("Unregistered commit cohort");
} catch (Exception e) {
return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION,
"Error closing commit cohort registration", e).buildFuture();
}
}
return RpcResultBuilder.<Void>success().buildFuture();
}
示例15: makeScrambledWithWheat
import org.opendaylight.yangtools.yang.common.RpcResult; //导入依赖的package包/类
@Override
public Boolean makeScrambledWithWheat() {
try {
// This call has to block since we must return a result to the JMX client.
RpcResult<Void> result = makeBreakfast(EggsType.SCRAMBLED, WheatBread.class, 2).get();
if (result.isSuccessful()) {
LOG.info("makeBreakfast succeeded");
} else {
LOG.warn("makeBreakfast failed: " + result.getErrors());
}
return result.isSuccessful();
} catch (InterruptedException | ExecutionException e) {
LOG.warn("An error occurred while maing breakfast: " + e);
}
return Boolean.FALSE;
}