本文整理汇总了Java中edu.uw.zookeeper.protocol.Operation类的典型用法代码示例。如果您正苦于以下问题:Java Operation类的具体用法?Java Operation怎么用?Java Operation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Operation类属于edu.uw.zookeeper.protocol包,在下文中一共展示了Operation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Builder
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
protected Builder(
ZxidGenerator zxids,
NameTrie<ZNodeNode> data,
SessionManager sessions,
ReentrantReadWriteLock lock,
Watches dataWatches,
Watches childWatches,
Function<Long, ? extends NotificationListener<Operation.ProtocolResponse<IWatcherEvent>>> listeners,
RuntimeModule runtime) {
this.zxids = zxids;
this.data = data;
this.sessions = sessions;
this.dataWatches = dataWatches;
this.childWatches = childWatches;
this.runtime = runtime;
this.listeners = listeners;
this.lock = lock;
}
示例2: ServerBuilder
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
protected ServerBuilder(
ServerConnectionFactoryBuilder connections,
SimpleServerSupplier server,
ConcurrentMap<Long, SimpleSessionExecutor> sessionExecutors,
ZxidGenerator zxids,
NameTrie<ZNodeNode> data,
SessionManager sessions,
ReentrantReadWriteLock lock,
Watches dataWatches,
Watches childWatches,
Function<Long, ? extends NotificationListener<Operation.ProtocolResponse<IWatcherEvent>>> listeners,
RuntimeModule runtime) {
super(zxids, data, sessions, lock, dataWatches, childWatches, listeners, runtime);
this.connections = checkNotNull(connections);
this.server = checkNotNull(server);
this.sessionExecutors = sessionExecutors;
}
示例3: post
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
public void post(final IWatcherEvent event) {
if (logger.isDebugEnabled()) {
logger.debug("{}", WatchEvent.fromRecord(event));
}
final ProtocolResponseMessage<IWatcherEvent> message = ProtocolResponseMessage.of(
OpCodeXid.NOTIFICATION.xid(),
OpCodeXid.NOTIFICATION_ZXID,
event);
String path = event.getPath();
for (Long session: byPath.removeAll(path)) {
bySession.remove(session, path);
NotificationListener<Operation.ProtocolResponse<IWatcherEvent>> listener = listeners.apply(session);
if (listener != null) {
listener.handleNotification(message);
}
}
}
示例4: run
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
@Override
public synchronized void run() {
if (!isDone()) {
// note that iterator calls are potentially blocking
if (task().hasNext()) {
Pair<? extends Records.Request, ? extends ListenableFuture<? extends Operation.ProtocolResponse<?>>> operation;
try {
operation = task().next();
} catch (Exception e) {
setException(e);
return;
}
pending.incrementAndGet();
new PendingOperation(operation.second());
executor.execute(this);
} else if (pending.get() == 0) {
set(null);
}
}
}
示例5: handleConnectionRead
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
@Override
public void handleConnectionRead(Operation.Response message) {
if (message instanceof Message.ServerResponse<?>) {
int xid = ((Message.ServerResponse<?>) message).xid();
if (! ((xid == OpCodeXid.PING.xid()) || (xid == OpCodeXid.NOTIFICATION.xid()))) {
Iterator<T> tasks = mailbox.iterator();
T task = null;
while (tasks.hasNext()) {
T next = tasks.next();
if ((next.xid() == xid) && !next.isDone()) {
task = next;
break;
}
}
if (task != null) {
task.set((Message.ServerResponse<?>) message);
} else if (state() != State.TERMINATED) {
// This could happen if someone submitted a message without
// going through us
// or, it could be a bug
logger.warn("{} xid doesn't match {} ({})", message, mailbox.peek(), this);
}
}
}
}
示例6: encode
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
/**
* Don't call concurrently!
*/
@Override
public void encode(Message.ClientSession input, ByteBuf output) throws IOException {
encoder.encode(input, output);
automaton.apply(input);
// we only need to remember xid -> opcode of pending messages
if (input instanceof Operation.RequestId) {
int xid = ((Operation.RequestId) input).xid();
if (! OpCodeXid.has(xid)) {
assert (input instanceof Operation.ProtocolRequest);
OpCode opcode = ((Operation.ProtocolRequest<?>) input).record().opcode();
Pair<Integer, OpCode> pair = Pair.create(xid, opcode);
pending.add(pair);
}
}
}
示例7: decode
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
/**
* Don't call concurrently!
*/
@Override
public Optional<Message.ServerSession> decode(ByteBuf input)
throws IOException {
Optional<Message.ServerSession> out = decoder.decode(input);
if (out.isPresent()) {
automaton.apply(out.get());
Message.ServerSession reply = out.get();
// the peek and poll need to be atomic
Pair<Integer, OpCode> next = pending.peek();
if ((next != null) && (reply instanceof Operation.RequestId)) {
if (next.first().equals(((Operation.RequestId) reply).xid())) {
pending.poll();
}
}
}
return out;
}
示例8: AbstractConnectionClientExecutor
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
protected AbstractConnectionClientExecutor(
ListenableFuture<ConnectMessage.Response> session,
C connection,
Listeners listeners,
TimeOutServer<Operation.Response> timer,
AtomicReference<Throwable> failure) {
this.session = session;
this.connection = connection;
this.listeners = listeners;
this.timer = timer;
this.failure = failure;
new TimeOutListener();
Futures.addCallback(this.session, this.timer);
this.connection.subscribe(this);
this.connection.codec().subscribe(this);
this.timer.run();
}
示例9: create
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
public static <I extends Operation.Request, O, T extends CodecConnection<? super I, ? extends O,? extends ProtocolCodec<?,?,?,?>,?>> ClientPingTask<I,O,T> create(
T connection,
TimeOutParameters parameters,
ScheduledExecutorService executor) {
Logger logger = LogManager.getLogger(ClientPingTask.class);
ClientPingTask<I,O,T> task = new ClientPingTask<I,O,T>(
connection,
parameters,
executor,
Sets.<Pair<Runnable,Executor>>newHashSet(),
SettableFuturePromise.<Void>create(),
logger);
LoggingFutureListener.listen(logger, task);
// TODO: replay connection events?
return task;
}
示例10: defaults
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
public static <C extends ProtocolConnection<? super Message.ClientSession, ? extends Operation.Response,?,?,?>> ServerViewFactory<Session, OperationClientExecutor<C>> defaults(
ClientConnectionFactory<C> connections,
ServerInetAddressView view,
TimeValue timeOut,
ScheduledExecutorService executor) {
ZxidTracker zxids = ZxidTracker.zero();
final DefaultsFactory<Session, ConnectMessage.Request> requestFactory = ConnectMessage.Request.factory(timeOut, zxids);
final FromRequestFactory<C> delegate =
FromRequestFactory.create(
FixedClientConnectionFactory.create(view.get(), connections),
executor);
return new ServerViewFactory<Session, OperationClientExecutor<C>>(
view,
new DefaultsFactory<Session, ListenableFuture<? extends OperationClientExecutor<C>>>() {
@Override
public ListenableFuture<OperationClientExecutor<C>> get() {
return delegate.get(requestFactory.get());
}
@Override
public ListenableFuture<OperationClientExecutor<C>> get(Session value) {
return delegate.get(requestFactory.get(value));
}
},
zxids);
}
示例11: deleteChildren
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
public static ListenableFuture<List<AbsoluteZNodePath>> deleteChildren(
final ZNodePath parent,
final ClientExecutor<? super Records.Request, ? extends Operation.ProtocolResponse<?>, ?> client) {
return Futures.transform(
GetChildren.create(
parent,
client,
SettableFuturePromise.<List<AbsoluteZNodePath>>create()),
new AsyncFunction<List<AbsoluteZNodePath>, List<AbsoluteZNodePath>>() {
@Override
public ListenableFuture<List<AbsoluteZNodePath>> apply(
List<AbsoluteZNodePath> children) throws Exception {
ImmutableList.Builder<ListenableFuture<AbsoluteZNodePath>> deletes = ImmutableList.builder();
for (AbsoluteZNodePath child: children) {
deletes.add(DeleteSubtree.deleteAll(child, client));
}
return Futures.allAsList(deletes.build());
}
});
}
示例12: onSuccess
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
@Override
public synchronized void onSuccess(DeleteLeaf result) {
checkArgument(result.isDone());
deletes.remove(this);
if (!result.isCancelled()) {
try {
for (Operation.ProtocolResponse<?> response: result.get()) {
Operations.maybeError(response.record(), KeeperException.Code.NONODE);
}
} catch (Exception e) {
onFailure(e);
}
Node parent = result.node().parent().get();
if (result.node().remove() && (parent != null) && (parent.isEmpty())) {
if (parent.path().length() >= root.length()) {
delete(parent);
} else {
// done!
promise.set(root);
}
}
}
}
示例13: call
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
@Override
public Optional<List<AbsoluteZNodePath>> call() throws Exception {
if (requests.isDone()) {
List<? extends Operation.ProtocolResponse<?>> responses = requests.get();
ImmutableList.Builder<AbsoluteZNodePath> children = ImmutableList.builder();
for (int i=0; i<requests.getValue().size(); ++i) {
Operation.ProtocolResponse<?> response = responses.get(i);
if (!Operations.maybeError(response.record(), KeeperException.Code.NONODE).isPresent()) {
if (response.record() instanceof Records.ChildrenGetter) {
ZNodePath prefix = ZNodePath.fromString(((Records.PathGetter) requests.getValue().get(i)).getPath());
for (String child: ((Records.ChildrenGetter) response.record()).getChildren()) {
children.add((AbsoluteZNodePath) prefix.join(ZNodeLabel.fromString(child)));
}
}
}
}
return Optional.<List<AbsoluteZNodePath>>of(children.build());
} else {
return Optional.absent();
}
}
示例14: getDefaultConnectionClientExecutorsService
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
@Override
protected ConnectionClientExecutorsService<Operation.Request, Session, OperationClientExecutor<?>> getDefaultConnectionClientExecutorsService() {
EnsembleView<ServerInetAddressView> ensemble = EnsembleViewConfiguration.get(getRuntimeModule().getConfiguration());
final EnsembleViewFactory<? extends ServerViewFactory<Session, ? extends OperationClientExecutor<?>>> ensembleFactory =
EnsembleViewFactory.fromSession(
getClientConnectionFactory(),
ensemble,
getConnectionBuilder().getTimeOut(),
getRuntimeModule().getExecutors().get(ScheduledExecutorService.class));
ConnectionClientExecutorsService<Operation.Request, Session, OperationClientExecutor<?>> service =
ConnectionClientExecutorsService.newInstance(
new DefaultsFactory<Session, ListenableFuture<? extends OperationClientExecutor<?>>>() {
@Override
public ListenableFuture<? extends OperationClientExecutor<?>> get(Session value) {
return ensembleFactory.get().get(value);
}
@Override
public ListenableFuture<? extends OperationClientExecutor<?>> get() {
return ensembleFactory.get().get();
}
});
return service;
}
示例15: handleNotification
import edu.uw.zookeeper.protocol.Operation; //导入依赖的package包/类
@Override
public void handleNotification(
Operation.ProtocolResponse<IWatcherEvent> notification) {
for (SessionListener listener: listeners) {
listener.handleNotification(notification);
}
}