Codota Logo
PrimitiveService.apply
Code IndexAdd Codota to your IDE (free)

How to use
apply
method
in
io.atomix.primitive.service.PrimitiveService

Best Java code snippets using io.atomix.primitive.service.PrimitiveService.apply (Showing top 6 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: atomix/atomix

try {
 currentSession = session;
 result = OperationResult.succeeded(currentIndex, eventIndex, service.apply(commit));
} catch (Exception e) {
 result = OperationResult.failed(currentIndex, eventIndex, e);
origin: atomix/atomix

byte[] output = service.apply(new DefaultCommit<>(
  currentIndex,
  operation.operationId(),
 currentOperation = OperationType.QUERY;
 try {
  output = service.apply(new DefaultCommit<>(
    currentIndex,
    pendingRead.operationId,
origin: atomix/atomix

/**
 * Applies the given commit to the state machine.
 */
private OperationResult applyCommand(long index, long sequence, long timestamp, PrimitiveOperation operation, RaftSession session) {
 long eventIndex = session.getEventIndex();
 Commit<byte[]> commit = new DefaultCommit<>(index, operation.id(), operation.value(), session, timestamp);
 OperationResult result;
 try {
  currentSession = session;
  // Execute the state machine operation and get the result.
  byte[] output = service.apply(commit);
  // Store the result for linearizability and complete the command.
  result = OperationResult.succeeded(index, eventIndex, output);
 } catch (Exception e) {
  // If an exception occurs during execution of the command, store the exception.
  result = OperationResult.failed(index, eventIndex, e);
 } finally {
  currentSession = null;
 }
 // Once the operation has been applied to the state machine, commit events published by the command.
 // The state machine context will build a composite future for events published to all sessions.
 commit();
 // Register the result in the session to ensure retries receive the same output for the command.
 session.registerResult(sequence, result);
 // Update the session timestamp and command sequence number.
 session.setCommandSequence(sequence);
 // Complete the command.
 return result;
}
origin: atomix/atomix

/**
 * Applies an execute operation to the service.
 */
private void applyExecute(ExecuteOperation operation) {
 Session session = context.getOrCreateSession(operation.session(), operation.node());
 if (operation.operation() != null) {
  try {
   context.service().apply(new DefaultCommit<>(
     context.setIndex(operation.index()),
     operation.operation().id(),
     operation.operation().value(),
     context.setSession(session),
     context.setTimestamp(operation.timestamp())));
  } catch (Exception e) {
   log.warn("Failed to apply operation: {}", e);
  } finally {
   context.setSession(null);
  }
 }
}
origin: atomix/atomix

private ExecuteResponse applyQuery(ExecuteRequest request, Session session) {
 try {
  byte[] result = context.service().apply(new DefaultCommit<>(
    context.getIndex(),
    request.operation().id(),
    request.operation().value(),
    context.setSession(session),
    context.currentTimestamp()));
  return ExecuteResponse.ok(result);
 } catch (Exception e) {
  return ExecuteResponse.error();
 } finally {
  context.setSession(null);
 }
}
origin: atomix/atomix

private CompletableFuture<ExecuteResponse> executeCommand(ExecuteRequest request) {
 PrimaryBackupSession session = context.getOrCreateSession(request.session(), request.node());
 long index = context.nextIndex();
 long timestamp = System.currentTimeMillis();
 return replicator.replicate(new ExecuteOperation(
   index,
   timestamp,
   session.sessionId().id(),
   session.memberId(),
   request.operation()))
   .thenApply(v -> {
    try {
     byte[] result = context.service().apply(new DefaultCommit<>(
       context.setIndex(index),
       request.operation().id(),
       request.operation().value(),
       context.setSession(session),
       context.setTimestamp(timestamp)));
     return ExecuteResponse.ok(result);
    } catch (Exception e) {
     return ExecuteResponse.error();
    } finally {
     context.setSession(null);
    }
   });
}
io.atomix.primitive.servicePrimitiveServiceapply

Popular methods of PrimitiveService

  • init
  • register
  • serializer
  • backup
  • close
  • expire
  • restore
  • tick

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • JButton (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now