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


Java Procedure类代码示例

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


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

示例1: doPersist

import akka.japi.Procedure; //导入依赖的package包/类
private <T> void doPersist(final T entry, final Procedure<T> procedure, final boolean async) {
    if (getDelegate().isRecoveryApplicable()) {
        persistSuper(entry, procedure, async);
    } else {
        if (entry instanceof ReplicatedLogEntry) {
            Payload payload = ((ReplicatedLogEntry)entry).getData();
            if (payload instanceof PersistentPayload) {
                // We persist the Payload but not the ReplicatedLogEntry to avoid gaps in the journal indexes
                // on recovery if data persistence is later enabled.
                if (async) {
                    persistentProvider.persistAsync(payload, p -> procedure.apply(entry));
                } else {
                    persistentProvider.persist(payload, p -> procedure.apply(entry));
                }
            } else {
                persistSuper(entry, procedure, async);
            }
        } else {
            persistSuper(entry, procedure, async);
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:RaftActorDelegatingPersistentDataProvider.java

示例2: testUpdateAndPersist

import akka.japi.Procedure; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testUpdateAndPersist() throws Exception {
    ElectionTermImpl impl = new ElectionTermImpl(mockPersistence, "test", LOG);

    impl.updateAndPersist(10, "member-1");

    assertEquals("getCurrentTerm", 10, impl.getCurrentTerm());
    assertEquals("getVotedFor", "member-1", impl.getVotedFor());

    ArgumentCaptor<Object> message = ArgumentCaptor.forClass(Object.class);
    ArgumentCaptor<Procedure> procedure = ArgumentCaptor.forClass(Procedure.class);
    verify(mockPersistence).persist(message.capture(), procedure.capture());

    assertEquals("Message type", UpdateElectionTerm.class, message.getValue().getClass());
    UpdateElectionTerm update = (UpdateElectionTerm)message.getValue();
    assertEquals("getCurrentTerm", 10, update.getCurrentTerm());
    assertEquals("getVotedFor", "member-1", update.getVotedFor());

    procedure.getValue().apply(null);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:22,代码来源:ElectionTermImplTest.java

示例3: testPersistWithPersistenceDisabled

import akka.japi.Procedure; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testPersistWithPersistenceDisabled() throws Exception {
    doReturn(false).when(mockDelegateProvider).isRecoveryApplicable();

    provider.persist(mockPersistentLogEntry, mockProcedure);

    ArgumentCaptor<Procedure> procedureCaptor = ArgumentCaptor.forClass(Procedure.class);
    verify(mockPersistentProvider).persist(eq(PERSISTENT_PAYLOAD), procedureCaptor.capture());
    verify(mockDelegateProvider, never()).persist(mockNonPersistentLogEntry, mockProcedure);
    procedureCaptor.getValue().apply(PERSISTENT_PAYLOAD);
    verify(mockProcedure).apply(mockPersistentLogEntry);

    provider.persist(mockNonPersistentLogEntry, mockProcedure);
    verify(mockDelegateProvider).persist(mockNonPersistentLogEntry, mockProcedure);

    provider.persist(OTHER_DATA_OBJECT, mockProcedure);
    verify(mockDelegateProvider).persist(OTHER_DATA_OBJECT, mockProcedure);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:RaftActorDelegatingPersistentDataProviderTest.java

示例4: waitForWorkIsDoneAck

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

示例5: onReceiveCommand

import akka.japi.Procedure; //导入依赖的package包/类
/**
 * Called on Command dispatch
 *
 * @param msg
 */
public void onReceiveCommand(Object msg) {
    log.info("Received Command: " + msg);
    if (msg instanceof Command) {
        final String data = ((Command) msg).getData();

        // generate an event we will persist after being enriched with a uuid
        final Event event = new Event(data, UUID.randomUUID().toString());

        // persist event and THEN update the state of the processor
        persist(event, new Procedure<Event>() {
            public void apply(Event evt) throws Exception {

                processorState.update(evt);

                // broadcast event on eventstream
                getContext().system().eventStream().publish(evt);
            }
        });
    } else if (msg.equals("snapshot")) {
        saveSnapshot(processorState.copy());
    } else if (msg.equals("printstate")) {
        log.info(processorState.toString());
    }
}
 
开发者ID:royrusso,项目名称:akka-java-examples,代码行数:30,代码来源:BaseProcessor.java

示例6: waitingForAck

import akka.japi.Procedure; //导入依赖的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: onReceiveCommitAck

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

示例8: onReceiveDatasetInfo

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

示例9: converting

import akka.japi.Procedure; //导入依赖的package包/类
private Procedure<Object> converting(Item<?> original, ActorRef sender) {
	return new Procedure<Object>() {

		@Override
		public void apply(Object msg) throws Exception {
			log.debug("converted item received: {}", msg);
			
			if(includeInStream(msg)) {
				log.debug("sending to consumer");
				sender.tell(new Item<>(original.getSequenceNumber(), msg), getSelf());
			} else {
				log.debug("skipping, requesting next item from producer");
				producer.tell(new NextItem(), getSelf());
			}
			
			getContext().become(receive());
		}
		
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:21,代码来源:StreamConverter.java

示例10: handshakeCompleted

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

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof Received) {			
				sendAppData(unwrap(msg));
			} else if(msg instanceof Tcp.Write) {
				sendNetData(wrap(msg));
			} if(msg instanceof ConnectionClosed) {
				listener.tell(msg, getSelf());
			} else {
				unhandled(msg);
			}
		}
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:18,代码来源:SSLHandler.java

示例11: waitingForAck

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

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof Ack) {
				log.debug("write acknowledged");
				
				unstashAll();
				getContext().unbecome();
			} else {
				stash();
			}
		}
		
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:18,代码来源:SSLHandler.java

示例12: tranceiving

import akka.japi.Procedure; //导入依赖的package包/类
public Procedure<Object> tranceiving(ActorRef peer, ActorRef handler) {
	log.debug("tranceiving: {} {}", peer, handler);
	
	unstashAll();
	
	return new Procedure<Object>() {

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof Tcp.Received) {
				log.debug("received: {}", getSelf());						
				
				handler.tell(msg, getSelf());
			} else if(msg instanceof Tcp.Write) {
				log.debug("write: {}", getSelf());
				
				Tcp.Write write = (Tcp.Write)msg;						
				getSender().tell(write.ack(), getSelf());
				peer.tell(new Tcp.Received(write.data()), getSelf());
			} else {
				unhandled(msg);
			}
		}
		
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:27,代码来源:SSLHandlerTest.java

示例13: connected

import akka.japi.Procedure; //导入依赖的package包/类
public Procedure<Object> connected(ActorRef peer) {
	log.debug("connected: {}", peer);
	
	unstashAll();
	
	return new Procedure<Object>() {

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof Tcp.Register) {
				log.debug("register");
				
				getContext().become(tranceiving(peer, ((Tcp.Register) msg).handler()));						
			} else {
				stash();
			}
		}
		
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:21,代码来源:SSLHandlerTest.java

示例14: beforeDelete

import akka.japi.Procedure; //导入依赖的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: waitingForDatasetStatusInfo

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

		@Override
		public void apply(Object msg) throws Exception {
			if(msg instanceof DatasetStatusInfo) {
				datasetStatus = (DatasetStatusInfo)msg;
				
				handleDatasetStatusInfo();
			} else {
				unhandled(msg);
			}
		}
		
	};
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:17,代码来源:VectorLoaderSessionInitiator.java


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