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


Java ReceiveTimeout类代码示例

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


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

示例1: onReceive

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
@Override
public void onReceive(Object message) {
    if (message instanceof CaptureSnapshotReply) {
        Snapshot snapshot = Snapshot.create(
                ((CaptureSnapshotReply)message).getSnapshotState(),
                params.captureSnapshot.getUnAppliedEntries(),
                params.captureSnapshot.getLastIndex(), params.captureSnapshot.getLastTerm(),
                params.captureSnapshot.getLastAppliedIndex(), params.captureSnapshot.getLastAppliedTerm(),
                params.electionTerm.getCurrentTerm(), params.electionTerm.getVotedFor(),
                params.peerInformation);

        LOG.debug("{}: Received CaptureSnapshotReply, sending {}", params.id, snapshot);

        params.replyToActor.tell(new GetSnapshotReply(params.id, snapshot), getSelf());
        getSelf().tell(PoisonPill.getInstance(), getSelf());
    } else if (message instanceof ReceiveTimeout) {
        LOG.warn("{}: Got ReceiveTimeout for inactivity - did not receive CaptureSnapshotReply within {} ms",
                params.id, params.receiveTimeout.toMillis());

        params.replyToActor.tell(new akka.actor.Status.Failure(new TimeoutException(String.format(
                "Timed out after %d ms while waiting for CaptureSnapshotReply",
                    params.receiveTimeout.toMillis()))), getSelf());
        getSelf().tell(PoisonPill.getInstance(), getSelf());
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:26,代码来源:GetSnapshotReplyActor.java

示例2: onReceive

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
@Override
public void onReceive(Object message) {
    if (message instanceof GetSnapshotReply) {
        onGetSnapshotReply((GetSnapshotReply)message);
    } else if (message instanceof Failure) {
        LOG.debug("{}: Received {}", params.id, message);

        params.replyToActor.tell(message, getSelf());
        getSelf().tell(PoisonPill.getInstance(), getSelf());
    } else if (message instanceof ReceiveTimeout) {
        String msg = String.format(
                "Timed out after %s ms while waiting for snapshot replies from %d shard(s). %d shard(s) %s "
                + "did not respond.", params.receiveTimeout.toMillis(), params.shardNames.size(),
                remainingShardNames.size(), remainingShardNames);
        LOG.warn("{}: {}", params.id, msg);
        params.replyToActor.tell(new Failure(new TimeoutException(msg)), getSelf());
        getSelf().tell(PoisonPill.getInstance(), getSelf());
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:ShardManagerGetSnapshotReplyActor.java

示例3: waitForWorkIsDoneAck

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
private Procedure<Object> waitForWorkIsDoneAck(final Object result) {
    return message -> {
        if (message instanceof Ack && ((Ack) message).workId.equals(jobId())) {
            sendToMaster(new MasterWorkerProtocol.WorkerRequestsWork(workerId, workerRole));
            getContext().setReceiveTimeout(Duration.Undefined());
            getContext().become(receiveBuilder()
                    .matchAny(p->idle.apply(p))
                    .build());
        } else if (message instanceof ReceiveTimeout) {
            log.info("No ack from master, retrying (" + workerId + " -> " + jobId() + ")");
            sendToMaster(new MasterWorkerProtocol.WorkIsDone(workerId, jobId(), result));
        } else {
            unhandled(message);
        }
    };
}
 
开发者ID:Abiy,项目名称:distGatling,代码行数:17,代码来源:Worker.java

示例4: createReceive

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
@Override
public Receive createReceive() {
  return receiveBuilder()
    .match(ActorIdentity.class, identity -> {
      calculator = identity.getRef();
      if (calculator == null) {
        System.out.println("Remote actor not available: " + path);
      } else {
        getContext().watch(calculator);
        getContext().become(active, true);
      }
    })
    .match(ReceiveTimeout.class, x -> {
      sendIdentifyRequest();
    })
    .build();
}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:18,代码来源:LookupActor.java

示例5: waitForWorkIsDoneAck

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
/**
    * After the worker sends the result of his work to the master he waits for 
    * the ACK of this message.
    * @param result
    * @return
    */
private Behavior waitForWorkIsDoneAck(final Object result) {
  return new Behavior() {
    public void apply(Object message) {
  	// The receive ACK message that mean Master receive the result of his work
      if (message instanceof Ack && ((Ack) message).workId.equals(workId())) {
      	// Worker ask for new work
        sendToMaster(new WorkerRequestsWork(workerId));
        getContext().setReceiveTimeout(Duration.Undefined());
        getContext().become(idle);
      }
      // if he does not receive ACK, worker resends a new WorkIsDone message
      else if (message instanceof ReceiveTimeout) {
        log.debug("No ack from master, retrying (" + workerId + " -> " + workId() + ")");
        sendToMaster(new WorkIsDone(workerId, workId(), result));
      }
      else {
        unhandled(message);
      }
    }
  };
}
 
开发者ID:awltech,项目名称:karajan,代码行数:28,代码来源:StepExecutor.java

示例6: waitingForAck

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
private Procedure<Object> waitingForAck() {
	return new Procedure<Object>() {

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof Ack) {
				log.debug("transaction committed");
				
				getContext().stop(getSelf());
			} else if(msg instanceof Failure) {
				log.error("failed to commit: {}", msg);
				
				sender.tell(msg, getSelf());
				getContext().stop(getSelf());
			} else if(msg instanceof ReceiveTimeout) {
				log.error("timout while committing");
				
				sender.tell(new Failure(new TimeoutException("while commiting")), getSelf());
				getContext().stop(getSelf());
			} else {
				unhandled(msg);
			}
		}
		
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:27,代码来源:VectorDatasetFetcher.java

示例7: onReceive

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
@Override
public void onReceive(Object msg) throws Exception {
	if(msg instanceof TransactionCreated) {
		log.debug("transaction created");
		
		try {
			databaseScheme = databaseConfig.getString("scheme");
		} catch(ConfigException.Missing cem) {
			databaseScheme = "SDE";
		}
		
		log.debug("database scheme before calling get fetch table: " + databaseScheme);
		
		transaction = ((TransactionCreated)msg).getActor();
		transaction.tell(SDEUtils.getFetchTable(SDEUtils.getItemsFilter(), databaseScheme), getSelf());
		
		getContext().become(onReceiveStreaming());
	} else if(msg instanceof ReceiveTimeout) {
		log.error("timeout received");
		getContext().stop(getSelf());
	} else {
		unhandled(msg);
	}
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:25,代码来源:SDEListDatasetInfoHandler.java

示例8: onReceiveCommitAck

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
protected Procedure<Object> onReceiveCommitAck() {
	return new Procedure<Object>() {

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof Ack) {
				log.debug("transaction finished");
				getContext().stop(getSelf());
			} else if(msg instanceof ReceiveTimeout) {
				log.error("timeout received");
				getContext().stop(getSelf());
			}
		}
		
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:17,代码来源:SDEListDatasetInfoHandler.java

示例9: onReceiveDatasetInfo

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
private Procedure<Object> onReceiveDatasetInfo() {
	return new Procedure<Object>() {

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof DatasetInfo) {
				log.debug("dataset info received");
				originalSender.tell(msg, getSelf());
				transaction.tell(new Commit(), getSelf());
				getContext().become(onReceiveCommitAck());
			} else if(msg instanceof ReceiveTimeout) {
				unavailable();
			} else {
				unhandled(msg);
			}
		}
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:19,代码来源:SDEGetDatasetInfoHandler.java

示例10: onReceive

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
@Override
public final void onReceive(Object msg) throws Exception {
	if(msg instanceof ReceiveTimeout) {
		log.error("timeout while collecting information");
		
		sender.tell(new Failure(new TimeoutException("collecting information")), getSelf());
		getContext().stop(getSelf());
	} else if(msg instanceof MetadataNotFound) {
		log.debug("metadata not found");
		
		sender.tell(new DatasetNotFound(((MetadataNotFound)msg).getIdentification()), getSelf());
		getContext().stop(getSelf());
	} else if(msg instanceof MetadataItem) {
		log.debug("metadata item");
		
		MetadataDocumentFactory metadataDocumentFactory = new MetadataDocumentFactory();
		MetadataDocument metadataDocument = metadataDocumentFactory.parseDocument(((MetadataItem)msg).getContent());
		
		handleMetadataDocument(metadataDocument);
	} else {			
		unhandled(msg);
	}
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:24,代码来源:AbstractDatasetFetcher.java

示例11: onReceive

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
@Override
public void onReceive(Object msg) throws Exception {
	if(msg instanceof ReceiveTimeout) {
		log.error("timeout");
		
		sendUnavailable();
	} else if(msg instanceof MetadataNotFound) {
		log.debug("metadata not found");
		
		tellTarget(new DatasetNotFound(((MetadataNotFound) msg).getIdentification()));
	} else if(msg instanceof MetadataItem) {
		log.debug("metadata item");
			
		handleMetadataItem((MetadataItem)msg);
	}  else {
		onReceiveElse(msg);
	}
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:19,代码来源:AbstractDatasetInfoBuilder.java

示例12: onReceive

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
@Override
public final void onReceive(Object msg) throws Exception {
	if(msg instanceof Commit) {
		handleCommit();
	} else if(msg instanceof Rollback) {
		handleRollback();
	} else if(msg instanceof Query) {
		handleQuery((Query)msg);
	} else if(msg instanceof StreamingQuery) {
		handleStreamingQuery((StreamingQuery)msg);
	} else if(msg instanceof ReceiveTimeout) {
		handleTimeout();
	} else if(msg instanceof Terminated) {
		handleTerminated((Terminated)msg);
	} else {
		unhandled(msg);
	}
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:19,代码来源:JdbcTransaction.java

示例13: onReceive

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
@Override
public void onReceive(Object msg) throws Exception {
	if(msg instanceof ReceiveTimeout) {
		log.error("timeout");
	} else {		
		log.debug("answer received");
		
		origSender.forward(msg, getContext());
		
		if(msg instanceof Failure) {
			log.debug("failure received");
		} else {
			log.debug("dispatching event messages");
			
			Event event = new Event(origMsg, msg);
			for(ActorRef listener : listeners) {
				listener.tell(event, getSelf());
			}
		}
	}
	
	getContext().stop(getSelf());
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:24,代码来源:EventDispatcher.java

示例14: beforeDelete

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
private Procedure<Object> beforeDelete(ActorRef sender, Class<?> entity) {
	return new Procedure<Object>() {

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof ReceiveTimeout) {
				log.error("timeout while waiting for beforeDelete to complete");
				
				sender.tell(new EventFailed(), getSelf());
				getContext().setReceiveTimeout(Duration.Inf());
				getContext().become(receive());
			} else if(msg instanceof BeforeCompleted) {
				log.debug("before completed");
				
				sender.tell(new EventWaiting(), getSelf());
				getContext().become(afterDelete(sender, entity, ((BeforeCompleted)msg).getResult()));
			} else {
				log.debug("message stashed: {} from {}", msg, getSender());
				
				stash();
			}
		}
		
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:26,代码来源:AbstractAdmin.java

示例15: become

import akka.actor.ReceiveTimeout; //导入依赖的package包/类
protected void become(String message, Procedure<Object> behavior) {
	log.debug("become: {}", message);
	
	getContext().become(new Procedure<Object>() {

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof ReceiveTimeout) {
				log.debug("receive timeout");
				
				if(!acknowledged) {
					acknowledgeJob();
				}
				
				jobContext.tell(new UpdateJobState(JobState.ABORTED), getSelf());
				
				getContext().stop(getSelf());
			} else {
				behavior.apply(msg);
			}
			
		}
	});
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:25,代码来源:AbstractLoaderSessionInitiator.java


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