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


Java PoisonPill类代码示例

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


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

示例1: testMajorityPropose

import akka.actor.PoisonPill; //导入依赖的package包/类
@Test
public void testMajorityPropose() throws Exception {
  final List<TestPriest> majorityTestPriests = Stream.generate(this::testPriest)
          .limit(PRIESTS_COUNT - MINORITY)
          .collect(toList());

  final List<TestPriest> minorityTestPriests = Stream.generate(this::testPriest)
          .limit(MINORITY)
          .collect(toList());

  final Set<ActorPath> priestsPaths = Stream
          .concat(majorityTestPriests.stream(), minorityTestPriests.stream())
          .map(p -> p.path)
          .collect(toSet());

  final List<TestKit> majorityKits = majorityTestPriests.stream().map(p -> p.kit).collect(toList());

  minorityTestPriests.forEach(p -> p.priest.tell(PoisonPill.getInstance(), ActorRef.noSender()));

  final ActorRef leader = system.actorOf(DecreePresident.props(new Cluster(priestsPaths), 1));
  leader.tell(new PaxosAPI.Propose("VALUE", 1), ActorRef.noSender());
  majorityKits.forEach(kit -> kit.expectMsg(new PaxosAPI.Decide("VALUE", 1)));
}
 
开发者ID:marnikitta,项目名称:Concierge,代码行数:24,代码来源:PaxosTest.java

示例2: testMinorityPropose

import akka.actor.PoisonPill; //导入依赖的package包/类
@Test
public void testMinorityPropose() throws Exception {
  final List<TestPriest> majorityTestPriests = Stream.generate(this::testPriest)
          .limit(PRIESTS_COUNT - MINORITY)
          .collect(toList());

  final List<TestPriest> minorityTestPriests = Stream.generate(this::testPriest)
          .limit(MINORITY)
          .collect(toList());

  final Set<ActorPath> priestsPaths = Stream
          .concat(majorityTestPriests.stream(), minorityTestPriests.stream())
          .map(p -> p.path)
          .collect(toSet());

  final List<TestKit> majorityKits = majorityTestPriests.stream().map(p -> p.kit).collect(toList());

  majorityTestPriests.forEach(p -> p.priest.tell(PoisonPill.getInstance(), ActorRef.noSender()));

  final ActorRef leader = system.actorOf(DecreePresident.props(new Cluster(priestsPaths), 1));
  leader.tell(new PaxosAPI.Propose("VALUE", 1), ActorRef.noSender());
  majorityKits.forEach(kit -> kit.expectNoMsg(Duration.create(1, SECONDS)));
}
 
开发者ID:marnikitta,项目名称:Concierge,代码行数:24,代码来源:PaxosTest.java

示例3: onReceive

import akka.actor.PoisonPill; //导入依赖的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

示例4: removeEntityOwnershipListener

import akka.actor.PoisonPill; //导入依赖的package包/类
void removeEntityOwnershipListener(String entityType, DOMEntityOwnershipListener listener) {
    LOG.debug("{}: Removing EntityOwnershipListener {} for entity type {}", logId, listener, entityType);

    listenerLock.writeLock().lock();
    try {
        if (entityTypeListenerMap.remove(entityType, listener)) {
            ListenerActorRefEntry listenerEntry = listenerActorMap.get(listener);

            LOG.debug("{}: Found {}", logId, listenerEntry);

            listenerEntry.referenceCount--;
            if (listenerEntry.referenceCount <= 0) {
                listenerActorMap.remove(listener);

                if (listenerEntry.actorRef != null) {
                    LOG.debug("Killing EntityOwnershipListenerActor {}", listenerEntry.actorRef);
                    listenerEntry.actorRef.tell(PoisonPill.getInstance(), ActorRef.noSender());
                }
            }
        }
    } finally {
        listenerLock.writeLock().unlock();
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:25,代码来源:EntityOwnershipListenerSupport.java

示例5: close

import akka.actor.PoisonPill; //导入依赖的package包/类
@Override
public void close() {

    boolean sendCloseMessage;
    synchronized (this) {
        sendCloseMessage = !closed && listenerRegistrationActor != null;
        closed = true;
    }

    if (sendCloseMessage) {
        listenerRegistrationActor.tell(CloseDataTreeNotificationListenerRegistration.getInstance(),
                ActorRef.noSender());
        listenerRegistrationActor = null;
    }

    if (dataChangeListenerActor != null) {
        dataChangeListenerActor.tell(PoisonPill.getInstance(), ActorRef.noSender());
        dataChangeListenerActor = null;
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:DataChangeListenerRegistrationProxy.java

示例6: onReceive

import akka.actor.PoisonPill; //导入依赖的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

示例7: onGetSnapshotReply

import akka.actor.PoisonPill; //导入依赖的package包/类
private void onGetSnapshotReply(GetSnapshotReply getSnapshotReply) {
    LOG.debug("{}: Received {}", params.id, getSnapshotReply);

    ShardIdentifier shardId = ShardIdentifier.fromShardIdString(getSnapshotReply.getId());
    shardSnapshots.add(new ShardSnapshot(shardId.getShardName(), getSnapshotReply.getSnapshot()));

    remainingShardNames.remove(shardId.getShardName());
    if (remainingShardNames.isEmpty()) {
        LOG.debug("{}: All shard snapshots received", params.id);

        DatastoreSnapshot datastoreSnapshot = new DatastoreSnapshot(params.datastoreType,
                params.shardManagerSnapshot, shardSnapshots);
        params.replyToActor.tell(datastoreSnapshot, getSelf());
        getSelf().tell(PoisonPill.getInstance(), getSelf());
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:ShardManagerGetSnapshotReplyActor.java

示例8: createDatastoreClient

import akka.actor.PoisonPill; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
private Entry<DataStoreClient, ActorRef> createDatastoreClient(
        final String shardName, final ActorContext actorContext)
        throws DOMDataTreeShardCreationFailedException {

    LOG.debug("{}: Creating distributed datastore client for shard {}", memberName, shardName);
    final Props distributedDataStoreClientProps =
            SimpleDataStoreClientActor.props(memberName, "Shard-" + shardName, actorContext, shardName);

    final ActorRef clientActor = actorSystem.actorOf(distributedDataStoreClientProps);
    try {
        return new SimpleEntry<>(SimpleDataStoreClientActor
                .getDistributedDataStoreClient(clientActor, 30, TimeUnit.SECONDS), clientActor);
    } catch (final Exception e) {
        LOG.error("{}: Failed to get actor for {}", distributedDataStoreClientProps, memberName, e);
        clientActor.tell(PoisonPill.getInstance(), noSender());
        throw new DOMDataTreeShardCreationFailedException(
                "Unable to create datastore client for shard{" + shardName + "}", e);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:DistributedShardedDOMDataTree.java

示例9: handleSnapshotMessage

import akka.actor.PoisonPill; //导入依赖的package包/类
private void handleSnapshotMessage(final Object message) {
    if (message instanceof SaveSnapshotFailure) {
        LOG.error("{}: failed to persist state", persistenceId(), ((SaveSnapshotFailure) message).cause());
        persisting = false;
        self().tell(PoisonPill.getInstance(), ActorRef.noSender());
    } else if (message instanceof SaveSnapshotSuccess) {
        LOG.debug("{}: got command: {}", persistenceId(), message);
        SaveSnapshotSuccess saved = (SaveSnapshotSuccess)message;
        deleteSnapshots(new SnapshotSelectionCriteria(saved.metadata().sequenceNr(),
                saved.metadata().timestamp() - 1, 0L, 0L));
        persisting = false;
        unstash();
    } else {
        LOG.debug("{}: stashing command {}", persistenceId(), message);
        stash();
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:BucketStoreActor.java

示例10: cancel

import akka.actor.PoisonPill; //导入依赖的package包/类
void cancel(long executionId, Throwable throwable) {
    ActorRef child = getContext().getChild(String.valueOf(executionId));
    if (child != null) {
        if (!scheduledTerminations.containsKey(child)) {
            getContext().watch(child);
            child.tell(new Status.Failure(throwable), getSelf());

            // Give the top-level interpreter some time to finish. Otherwise, we will terminate it after a timeout.
            Cancellable scheduledTermination = getContext().system().scheduler().scheduleOnce(
                Duration.create(1, TimeUnit.MINUTES),
                child,
                PoisonPill.getInstance(),
                getContext().dispatcher(),
                getSelf()
            );
            scheduledTerminations.put(child, scheduledTermination);
        }
    } else {
        log.warning("Request to cancel unknown execution {} because of: {}", executionId, throwable);
    }
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:22,代码来源:MasterInterpreterActor.java

示例11: tearDownCluster

import akka.actor.PoisonPill; //导入依赖的package包/类
@AfterClass
public static void tearDownCluster() throws Exception {
	if (highAvailabilityServices != null) {
		highAvailabilityServices.closeAndCleanupAllData();
	}

	if (actorSystem != null) {
		actorSystem.shutdown();
	}

	if (archiver != null) {
		archiver.actor().tell(PoisonPill.getInstance(), ActorRef.noSender());
	}

	if (jobManager != null) {
		jobManager.actor().tell(PoisonPill.getInstance(), ActorRef.noSender());
	}

	if (taskManager != null) {
		taskManager.actor().tell(PoisonPill.getInstance(), ActorRef.noSender());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:AbstractOperatorRestoreTestBase.java

示例12: run

import akka.actor.PoisonPill; //导入依赖的package包/类
@Override
public void run() {
    while(true) {
        try {
            Serializable message = function.apply(null);

            ObjectNode node = Json.newObject();
            node.put("type", messageType);
            node.put("id", id);
            node.put("value", Json.toJson(message));
            out.tell(node.toString(),self);
            Thread.sleep(interval);
        } catch (Exception e) {
            Logger.error(e.getMessage(),e);
            self.tell(PoisonPill.getInstance(), self());
        }
    }
}
 
开发者ID:ugent-cros,项目名称:cros-core,代码行数:19,代码来源:TestWebSocket.java

示例13: onReceive

import akka.actor.PoisonPill; //导入依赖的package包/类
/**
 * This message is called receipt of data of type I (from upstream pipes).
 * It ingests the message to produce an object of type O and sends it downstream.
 * Null handling of messages occurs here, there is no need for it to be implemented
 * in the 'ingest' method.
 * @param message The object that is received for processing.
 */
@Override
@SuppressWarnings("unchecked")
public final void onReceive(Object message) {
    if (message != null) {
        if(message instanceof  InitializationMessage) {
            initializePipe((InitializationMessage)message);
        } else if (message instanceof StopMessage) {
            receivedStopMessages++;
            if (receivedStopMessages.equals(upstreamPipeCount)) {
                downstreamPipes.forEach(x -> x.tell(new StopMessage(), this.getSelf()));
                this.getSelf().tell(PoisonPill.getInstance(), this.getSelf());
            }
        }
        else{
            I inbound = (I) message;
            O outbound = ingest(inbound);
            send(outbound);
        }
    }
}
 
开发者ID:collinscangarella,项目名称:AkkaPipes,代码行数:28,代码来源:AbstractPipe.java

示例14: handleRollback

import akka.actor.PoisonPill; //导入依赖的package包/类
private void handleRollback() throws SQLException {
	log.debug("rolling back transaction");
	
	ActorRef sender = getSender(), self = getSelf();
	executorService.execute(() -> {
		try {
			connection.rollback();
			sender.tell(new Ack(), self);
		} catch(Exception e) {
			log.error("rollback failed: {}", e);
			
			sender.tell(new Failure(e), self);
		}
		
		self.tell(PoisonPill.getInstance(), self);
	});
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:18,代码来源:JdbcTransaction.java

示例15: handleCommit

import akka.actor.PoisonPill; //导入依赖的package包/类
private void handleCommit() throws SQLException {
	log.debug("committing transaction");
	
	ActorRef sender = getSender(), self = getSelf();
	executorService.execute(() -> {
		try {
			connection.commit();
			sender.tell(new Ack(), self);
		} catch(Exception e) {
			log.error("commit failed: {}", e);
			
			sender.tell(new Failure(e), self);
		}
		
		self.tell(PoisonPill.getInstance(), self);
	});
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:18,代码来源:JdbcTransaction.java


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