Tabnine Logo
PrimitiveService.apply
Code IndexAdd Tabnine 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)

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

  • Updating database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • notifyDataSetChanged (ArrayAdapter)
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now