本文整理汇总了Java中akka.actor.ActorSelection.tell方法的典型用法代码示例。如果您正苦于以下问题:Java ActorSelection.tell方法的具体用法?Java ActorSelection.tell怎么用?Java ActorSelection.tell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类akka.actor.ActorSelection
的用法示例。
在下文中一共展示了ActorSelection.tell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processListenerRegistrationMessage
import akka.actor.ActorSelection; //导入方法依赖的package包/类
protected ActorSelection processListenerRegistrationMessage(M message) {
final ActorSelection listenerActor = selectActor(message.getListenerActorPath());
// We have a leader so enable the listener.
listenerActor.tell(new EnableNotification(true, persistenceId()), getSelf());
if (!message.isRegisterOnAllInstances()) {
// This is a leader-only registration so store a reference to the listener actor so it can be notified
// at a later point if notifications should be enabled or disabled.
leaderOnlyListenerActors.add(listenerActor);
}
allListenerActors.add(listenerActor);
return listenerActor;
}
示例2: onMakeLeaderLocal
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void onMakeLeaderLocal() {
LOG.debug("{}: onMakeLeaderLocal received", persistenceId());
if (isLeader()) {
getSender().tell(new Status.Success(null), getSelf());
return;
}
final ActorSelection leader = getLeader();
if (leader == null) {
// Leader is not present. The cluster is most likely trying to
// elect a leader and we should let that run its normal course
// TODO we can wait for the election to complete and retry the
// request. We can also let the caller retry by sending a flag
// in the response indicating the request is "reTryable".
getSender().tell(new Failure(
new LeadershipTransferFailedException("We cannot initiate leadership transfer to local node. "
+ "Currently there is no leader for " + persistenceId())),
getSelf());
return;
}
leader.tell(new RequestLeadership(getId(), getSender()), getSelf());
}
示例3: setListenerRegistrationActor
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void setListenerRegistrationActor(ActorSelection listenerRegistrationActor) {
if (listenerRegistrationActor == null) {
return;
}
boolean sendCloseMessage = false;
synchronized (this) {
if (closed) {
sendCloseMessage = true;
} else {
this.listenerRegistrationActor = listenerRegistrationActor;
}
}
if (sendCloseMessage) {
listenerRegistrationActor.tell(CloseDataTreeNotificationListenerRegistration.getInstance(),
ActorRef.noSender());
}
}
示例4: queryFhirBundleResources
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void queryFhirBundleResources(MediatorHTTPRequest request)
{
originalRequest = request;
ActorSelection httpConnector = getContext().actorSelection(config.userPathFor("http-connector"));
Map <String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
String resourceInformation="FHIR CSV resources";
log.info("Querying the CSV Fhir service");
//builtRequestPath="/baseDstu3/Practitioner?_lastUpdated=>=2016-10-11T09:12:37&_lastUpdated=<=2016-10-13T09:12:45&_pretty=true";
String ServerApp=mediatorConfiguration.getServerTargetAppName().equals("null")?null:mediatorConfiguration.getServerTargetAppName();
baseServerRepoURI=FhirMediatorUtilities.buidServerRepoBaseUri(
this.mediatorConfiguration.getServerTargetscheme(),
this.mediatorConfiguration.getServerTargetURI(),
this.mediatorConfiguration.getServerTargetPort(),
ServerApp,
this.mediatorConfiguration.getServerTargetFhirDataModel()
);
String uriRepServer=baseServerRepoURI+FhirMediatorUtilities.buildBundleSearchRequestByType();
String encodedUriSourceServer=FhirMediatorUtilities.encodeUrlToHttpFormat(uriRepServer);
MediatorHTTPRequest serviceRequest = new MediatorHTTPRequest(
request.getRequestHandler(),
getSelf(),
resourceInformation,
"GET",
encodedUriSourceServer,
null,
headers,
null);
resultOutPutHeader+="requestDateTime:"+new Date().toString()+",";
httpConnector.tell(serviceRequest, getSelf());
}
示例5: testClusteredDataTreeChangeListenerWithDelayedRegistrationClosed
import akka.actor.ActorSelection; //导入方法依赖的package包/类
@Test
public void testClusteredDataTreeChangeListenerWithDelayedRegistrationClosed() throws Exception {
new ShardTestKit(getSystem()) {
{
final String testName = "testClusteredDataTreeChangeListenerWithDelayedRegistrationClosed";
dataStoreContextBuilder.shardElectionTimeoutFactor(1000)
.customRaftPolicyImplementation(DisableElectionsRaftPolicy.class.getName());
final MockDataTreeChangeListener listener = new MockDataTreeChangeListener(0);
final ActorRef dclActor = actorFactory.createActor(DataTreeChangeListenerActor.props(listener,
TestModel.TEST_PATH), actorFactory.generateActorId(testName + "-DataTreeChangeListener"));
setupInMemorySnapshotStore();
final TestActorRef<Shard> shard = actorFactory.createTestActor(
newShardBuilder().props().withDispatcher(Dispatchers.DefaultDispatcherId()),
actorFactory.generateActorId(testName + "-shard"));
waitUntilNoLeader(shard);
shard.tell(new RegisterDataTreeChangeListener(TestModel.TEST_PATH, dclActor, true), getRef());
final RegisterDataTreeNotificationListenerReply reply = expectMsgClass(duration("5 seconds"),
RegisterDataTreeNotificationListenerReply.class);
assertNotNull("getListenerRegistrationPath", reply.getListenerRegistrationPath());
final ActorSelection regActor = getSystem().actorSelection(reply.getListenerRegistrationPath());
regActor.tell(CloseDataTreeNotificationListenerRegistration.getInstance(), getRef());
expectMsgClass(CloseDataTreeNotificationListenerRegistrationReply.class);
shard.tell(DatastoreContext.newBuilderFrom(dataStoreContextBuilder.build())
.customRaftPolicyImplementation(null).build(), ActorRef.noSender());
listener.expectNoMoreChanges("Received unexpected change after close");
}
};
}
示例6: queryDHIS2FhirRepositoryResources
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void queryDHIS2FhirRepositoryResources(MediatorHTTPRequest request)
{
originalRequest = request;
ActorSelection httpConnector = getContext().actorSelection(config.userPathFor("http-connector"));
Map <String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
String resourceInformation="FHIR Trackers resources";
log.info("Querying the DHIS2 tracker server");
//builtRequestPath="/baseDstu3/Practitioner?_lastUpdated=>=2016-10-11T09:12:37&_lastUpdated=<=2016-10-13T09:12:45&_pretty=true";
String ServerApp=mediatorConfiguration.getServerSourceAppName().equals("null")?null:mediatorConfiguration.getServerSourceAppName();
baseServerRepoURI=FhirMediatorUtilities.buidServerRepoBaseUri(
this.mediatorConfiguration.getSourceServerScheme(),
this.mediatorConfiguration.getSourceServerURI(),
this.mediatorConfiguration.getSourceServerPort(),
ServerApp,
this.mediatorConfiguration.getSourceServerFhirDataModel()
);
String uriRepServer=baseServerRepoURI;
String encodedUriSourceServer=FhirMediatorUtilities.encodeUrlToHttpFormat(uriRepServer);
MediatorHTTPRequest serviceRequest = new MediatorHTTPRequest(
request.getRequestHandler(),
getSelf(),
resourceInformation,
"GET",
encodedUriSourceServer,
null,
headers,
null);
resultOutPutHeader+="requestDateTime:"+new Date().toString()+",";
httpConnector.tell(serviceRequest, getSelf());
}
示例7: processNewCome
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void processNewCome(long serverUId, String remotePath) {
// msg.remotePath=akka.tcp://[email protected]:25514
String fixSupervisorPath = AkkaUtil.getFixSupervisorPath(remotePath, WorldActor.IDENTIFY);
ActorSelection remoteActorSelection = AkkaUtil.getRemoteActorSelection(fixSupervisorPath);
HandShake handShake = new HandShake(ServerEngine.serverId, serverUId);
byte[] actorMessageWithSubClass = thriftSerializerFactory.getActorMessageByteArray(Operation.WORLD_HAND_SHAKE, handShake);
remoteActorSelection.tell(actorMessageWithSubClass, getSelf());
}
示例8: init
import akka.actor.ActorSelection; //导入方法依赖的package包/类
void init() {
RaftActorContext context = raftActor.getRaftActorContext();
RaftActorBehavior currentBehavior = raftActor.getCurrentBehavior();
transferTimer.start();
Optional<ActorRef> roleChangeNotifier = raftActor.getRoleChangeNotifier();
if (roleChangeNotifier.isPresent()) {
roleChangeNotifier.get().tell(raftActor.newLeaderStateChanged(context.getId(), null,
currentBehavior.getLeaderPayloadVersion()), raftActor.self());
}
for (String peerId: context.getPeerIds()) {
ActorSelection followerActor = context.getPeerActorSelection(peerId);
if (followerActor != null) {
followerActor.tell(new LeaderTransitioning(context.getId()), context.getActor());
}
}
raftActor.pauseLeader(new TimedRunnable(context.getConfigParams().getElectionTimeOutInterval(), raftActor) {
@Override
protected void doRun() {
LOG.debug("{}: pauseLeader successfully completed - doing transfer", raftActor.persistenceId());
doTransfer();
}
@Override
protected void doCancel() {
LOG.debug("{}: pauseLeader timed out - continuing with transfer", raftActor.persistenceId());
doTransfer();
}
});
}
示例9: sendOperationAsync
import akka.actor.ActorSelection; //导入方法依赖的package包/类
/**
* Sends an operation to be executed by a remote actor asynchronously without waiting for a
* reply (essentially set and forget).
*
* @param actor the ActorSelection
* @param message the message to send
*/
public void sendOperationAsync(ActorSelection actor, Object message) {
Preconditions.checkArgument(actor != null, "actor must not be null");
Preconditions.checkArgument(message != null, "message must not be null");
LOG.debug("Sending message {} to {}", message.getClass(), actor);
actor.tell(message, ActorRef.noSender());
}
示例10: startNewTerm
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void startNewTerm() {
// set voteCount back to 1 (that is voting for self)
voteCount = 1;
// Increment the election term and vote for self
long currentTerm = context.getTermInformation().getCurrentTerm();
long newTerm = currentTerm + 1;
context.getTermInformation().updateAndPersist(newTerm, context.getId());
log.info("{}: Starting new election term {}", logName(), newTerm);
// Request for a vote
// TODO: Retry request for vote if replies do not arrive in a reasonable
// amount of time TBD
for (String peerId : votingPeers) {
ActorSelection peerActor = context.getPeerActorSelection(peerId);
if (peerActor != null) {
RequestVote requestVote = new RequestVote(
context.getTermInformation().getCurrentTerm(),
context.getId(),
context.getReplicatedLog().lastIndex(),
context.getReplicatedLog().lastTerm());
log.debug("{}: Sending {} to peer {}", logName(), requestVote, peerId);
peerActor.tell(requestVote, context.getActor());
}
}
}
示例11: onNewOperation
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void onNewOperation(ServerOperationContext<?> operationContext) {
if (raftActor.isLeader()) {
currentOperationState.onNewOperation(operationContext);
} else {
ActorSelection leader = raftActor.getLeader();
if (leader != null) {
LOG.debug("{}: Not leader - forwarding to leader {}", raftContext.getId(), leader);
leader.tell(operationContext.getOperation(), operationContext.getClientRequestor());
} else {
LOG.debug("{}: No leader - returning NO_LEADER reply", raftContext.getId());
operationContext.getClientRequestor().tell(operationContext.newReply(
ServerChangeStatus.NO_LEADER, null), raftActor.self());
}
}
}
示例12: saveEvent
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void saveEvent(ResolveEventRequest request)
{
originalRequest = request;
String authentication=mediatorConfiguration.getAuthentication();
String authEncoded = Base64.encodeBytes(authentication.getBytes());
ActorSelection httpConnector = getContext().actorSelection(config.userPathFor("http-connector"));
Map <String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
headers.put("Content-Type","application/json");
headers.put("Authorization","Basic "+authEncoded);
String resourceInformation="Dhis2 event resources to push";
log.info("Querying the HAPI Test servers");
String builtRequestPath="";
builtRequestPath="/events";
String paramsRequest="";
paramsRequest=request.getRequestObject();
String requestBody=paramsRequest;
//builtRequestPath=FhirMediatorUtilities.buildResourcesSearchRequestByIds("Condition",paramsRequest);
//builtRequestPath=request.getRequestObject();
String ServerApp="";
String baseServerRepoURI="";
try
{
ServerApp=mediatorConfiguration.getServerTrackerAppName().equals("null")?null:mediatorConfiguration.getServerTrackerAppName();
baseServerRepoURI=FhirMediatorUtilities.buidServerRepoBaseUri(
this.mediatorConfiguration.getServerTrackerScheme(),
this.mediatorConfiguration.getServerTrackerURI(),
this.mediatorConfiguration.getServerTrackerPort(),
ServerApp,
this.mediatorConfiguration.getServerTrackerFhirDataModel()
);
}
catch (Exception exc)
{
log.error(exc.getMessage());
//throw new Exception(exc.getMessage());
FhirMediatorUtilities.writeInLogFile(this.mediatorConfiguration.getLogFile(),
exc.getMessage(),"Error");
return;
}
//String uriRepServer=baseServerRepoURI+"/Practitioner?_lastUpdated=%3E=2016-10-11T09:12:37&_lastUpdated=%3C=2016-10-13T09:12:45&_pretty=true";
String uriRepServer=baseServerRepoURI+builtRequestPath;
String encodedUriSourceServer=FhirMediatorUtilities.encodeUrlToHttpFormat(uriRepServer);
MediatorHTTPRequest serviceRequest = new MediatorHTTPRequest(
request.getRequestHandler(),
getSelf(),
resourceInformation,
"POST",
encodedUriSourceServer,
requestBody,
headers,
null);
httpConnector.tell(serviceRequest, getSelf());
}
示例13: queryOrganization
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void queryOrganization(ResolveOrganizationRequest request)
{
originalRequest = request;
ActorSelection httpConnector = getContext().actorSelection(config.userPathFor("http-connector"));
Map <String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
String resourceInformation="FHIR Practitioners resources";
log.info("Querying the HAPI Test servers");
String builtRequestPath="";
List<String> paramsRequest=new ArrayList<>();
paramsRequest=request.getRequestObject();
builtRequestPath=FhirMediatorUtilities.buildResourcesSearchRequestByIds("Organization",paramsRequest);
//builtRequestPath=request.getRequestObject();
String ServerApp="";
String baseServerRepoURI="";
try
{
ServerApp=mediatorConfiguration.getServerTargetAppName().equals("null")?null:mediatorConfiguration.getServerTargetAppName();
baseServerRepoURI=FhirMediatorUtilities.buidServerRepoBaseUri(
this.mediatorConfiguration.getServerTargetscheme(),
this.mediatorConfiguration.getServerTargetURI(),
this.mediatorConfiguration.getServerTargetPort(),
ServerApp,
this.mediatorConfiguration.getServerTargetFhirDataModel()
);
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(this.mediatorConfiguration.getLogFile(),
exc.getMessage(),"Error");
log.error(exc.getMessage());
return;
}
//String uriRepServer=baseServerRepoURI+"/Practitioner?_lastUpdated=%3E=2016-10-11T09:12:37&_lastUpdated=%3C=2016-10-13T09:12:45&_pretty=true";
String uriRepServer=baseServerRepoURI+builtRequestPath;
String encodedUriSourceServer=FhirMediatorUtilities.encodeUrlToHttpFormat(uriRepServer);
MediatorHTTPRequest serviceRequest = new MediatorHTTPRequest(
request.getRequestHandler(),
getSelf(),
resourceInformation,
"GET",
encodedUriSourceServer,
null,
headers,
null);
httpConnector.tell(serviceRequest, getSelf());
}
示例14: queryDiagnosticOrder
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void queryDiagnosticOrder(ResolveDiagnosticOrderRequest request)
{
originalRequest = request;
ActorSelection httpConnector = getContext().actorSelection(config.userPathFor("http-connector"));
Map <String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
String resourceInformation="FHIR Diagnostic Order resources";
log.info("Querying the HAPI Test servers");
String builtRequestPath="";
List<String> paramsRequest=new ArrayList<>();
paramsRequest=request.getRequestObject();
builtRequestPath=FhirMediatorUtilities.buildResourcesSearchRequestByIds("DiagnosticOrder",paramsRequest);
//builtRequestPath=request.getRequestObject();
String ServerApp="";
String baseServerRepoURI="";
try
{
ServerApp=mediatorConfiguration.getServerTargetAppName().equals("null")?null:mediatorConfiguration.getServerTargetAppName();
baseServerRepoURI=FhirMediatorUtilities.buidServerRepoBaseUri(
this.mediatorConfiguration.getServerTargetscheme(),
this.mediatorConfiguration.getServerTargetURI(),
this.mediatorConfiguration.getServerTargetPort(),
ServerApp,
this.mediatorConfiguration.getServerTargetFhirDataModel()
);
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(this.mediatorConfiguration.getLogFile(),
exc.getMessage(),"Error");
log.error(exc.getMessage());
return;
}
//String uriRepServer=baseServerRepoURI+"/Practitioner?_lastUpdated=%3E=2016-10-11T09:12:37&_lastUpdated=%3C=2016-10-13T09:12:45&_pretty=true";
String uriRepServer=baseServerRepoURI+builtRequestPath;
String encodedUriSourceServer=FhirMediatorUtilities.encodeUrlToHttpFormat(uriRepServer);
MediatorHTTPRequest serviceRequest = new MediatorHTTPRequest(
request.getRequestHandler(),
getSelf(),
resourceInformation,
"GET",
encodedUriSourceServer,
null,
headers,
null);
httpConnector.tell(serviceRequest, getSelf());
}
示例15: queryDiagnosticReport
import akka.actor.ActorSelection; //导入方法依赖的package包/类
private void queryDiagnosticReport(ResolveDiagnosticReportRequest request)
{
originalRequest = request;
ActorSelection httpConnector = getContext().actorSelection(config.userPathFor("http-connector"));
Map <String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
String resourceInformation="FHIR Diagnostic Report resources";
log.info("Querying the HAPI Test servers");
String builtRequestPath="";
List<String> paramsRequest=new ArrayList<>();
paramsRequest=request.getRequestObject();
builtRequestPath=FhirMediatorUtilities.buildResourcesSearchRequestByIds("DiagnosticReport",paramsRequest);
//builtRequestPath=request.getRequestObject();
String ServerApp="";
String baseServerRepoURI="";
try
{
ServerApp=mediatorConfiguration.getServerTargetAppName().equals("null")?null:mediatorConfiguration.getServerTargetAppName();
baseServerRepoURI=FhirMediatorUtilities.buidServerRepoBaseUri(
this.mediatorConfiguration.getServerTargetscheme(),
this.mediatorConfiguration.getServerTargetURI(),
this.mediatorConfiguration.getServerTargetPort(),
ServerApp,
this.mediatorConfiguration.getServerTargetFhirDataModel()
);
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(this.mediatorConfiguration.getLogFile(),
exc.getMessage(),"Error");
log.error(exc.getMessage());
return;
}
//String uriRepServer=baseServerRepoURI+"/Practitioner?_lastUpdated=%3E=2016-10-11T09:12:37&_lastUpdated=%3C=2016-10-13T09:12:45&_pretty=true";
String uriRepServer=baseServerRepoURI+builtRequestPath;
String encodedUriSourceServer=FhirMediatorUtilities.encodeUrlToHttpFormat(uriRepServer);
MediatorHTTPRequest serviceRequest = new MediatorHTTPRequest(
request.getRequestHandler(),
getSelf(),
resourceInformation,
"GET",
encodedUriSourceServer,
null,
headers,
null);
httpConnector.tell(serviceRequest, getSelf());
}