Tabnine Logo
Segment.getSegmentId
Code IndexAdd Tabnine to your IDE (free)

How to use
getSegmentId
method
in
org.axonframework.eventhandling.Segment

Best Java code snippets using org.axonframework.eventhandling.Segment.getSegmentId (Showing top 20 results out of 315)

origin: AxonFramework/AxonFramework

/**
 * Indicates whether this segment can be merged with the given {@code other} segment.
 * <p>
 * Two segments can be merged when their mask is identical, and the only difference in SegmentID is in the first
 * 1-bit of their mask.
 *
 * @param other the Segment to verify mergeability for
 * @return {@code true} if the segments can be merged, otherwise {@code false}
 */
public boolean isMergeableWith(Segment other) {
  return this.mask == other.mask
      && mergeableSegmentId() == other.getSegmentId();
}
origin: AxonFramework/AxonFramework

@Override
public String toString() {
  return String.format("Segment[%d/%s]", getSegmentId(), getMask());
}
origin: AxonFramework/AxonFramework

private static boolean computeSegments(Segment segment, List<Integer> segments, Set<Segment> applicableSegments) {
  final Segment[] splitSegment = segment.split();
  // As the first segmentId mask, keeps the original segmentId, we only check the 2nd segmentId mask being a know.
  if (segments.contains(splitSegment[1].getSegmentId())) {
    for (Segment segmentSplit : splitSegment) {
      if (!computeSegments(segmentSplit, segments, applicableSegments)) {
        applicableSegments.add(segmentSplit);
      }
    }
  } else {
    applicableSegments.add(segment);
  }
  return true;
}
origin: AxonFramework/AxonFramework

private void checkSegmentCaughtUp(Segment segment, BlockingStream<TrackedEventMessage<?>> eventStream) {
  if (!eventStream.hasNextAvailable()) {
    activeSegments.computeIfPresent(segment.getSegmentId(), (k, v) -> v.caughtUp());
  }
}
origin: AxonFramework/AxonFramework

@Override
public void run() {
  try {
    processingLoop(segment);
  } catch (Throwable e) {
    logger.error("Processing loop ended due to uncaught exception. Pausing processor in Error State.", e);
    state.set(State.PAUSED_ERROR);
  } finally {
    activeSegments.remove(segment.getSegmentId());
    if (availableThreads.getAndIncrement() == 0 && getState().isRunning()) {
      logger.info("No Worker Launcher active. Using current thread to assign segments.");
      new WorkerLauncher().run();
    }
  }
}
origin: AxonFramework/AxonFramework

private void releaseToken(Segment segment) {
  try {
    transactionManager.executeInTransaction(() -> tokenStore.releaseClaim(getName(), segment.getSegmentId()));
  } catch (Exception e) {
    // Ignore exception
  }
}
origin: AxonFramework/AxonFramework

private BlockingStream<TrackedEventMessage<?>> ensureEventStreamOpened(
    BlockingStream<TrackedEventMessage<?>> eventStreamIn, Segment segment) {
  BlockingStream<TrackedEventMessage<?>> eventStream = eventStreamIn;
  if (eventStream == null && state.get().isRunning()) {
    final TrackingToken trackingToken = transactionManager.fetchInTransaction(
        () -> tokenStore.fetchToken(getName(), segment.getSegmentId())
    );
    logger.info("Fetched token: {} for segment: {}", trackingToken, segment);
    eventStream = transactionManager.fetchInTransaction(
        () -> doOpenStream(trackingToken));
  }
  return eventStream;
}
origin: AxonFramework/AxonFramework

Segment segment = segments[i];
if (!activeSegments.containsKey(segment.getSegmentId())
    && canClaimSegment(segment.getSegmentId())) {
  try {
    transactionManager.executeInTransaction(() -> {
      TrackingToken token = tokenStore.fetchToken(processorName, segment.getSegmentId());
      activeSegments.putIfAbsent(segment.getSegmentId(), new TrackerStatus(segment, token));
    });
  } catch (UnableToClaimTokenException ucte) {
           segment.getSegmentId());
    activeSegments.remove(segment.getSegmentId());
    continue;
  } catch (Exception e) {
    activeSegments.remove(segment.getSegmentId());
    if (AxonNonTransientException.isCauseOf(e)) {
      logger.error(
          "An unrecoverable error has occurred wile attempting to claim a token "
              + "for segment: {}. Shutting down processor [{}].",
          segment.getSegmentId(),
          getName(),
        "An error occurred while attempting to claim a token for segment: {}. "
            + "Will retry later...",
        segment.getSegmentId(),
origin: AxonFramework/AxonFramework

long errorWaitTime = 1;
try {
  while (state.get().isRunning() && canClaimSegment(segment.getSegmentId())) {
    try {
      eventStream = ensureEventStreamOpened(eventStream, segment);
    } catch (UnableToClaimTokenException e) {
      logger.info("Segment is owned by another node. Releasing thread to process another segment...");
      releaseSegment(segment.getSegmentId());
    } catch (Exception e) {
origin: AxonFramework/AxonFramework

      TrackingToken finalLastToken = lastToken;
      transactionManager.executeInTransaction(
          () -> tokenStore.storeToken(finalLastToken, getName(), segment.getSegmentId())
      );
      activeSegments.computeIfPresent(segment.getSegmentId(), (k, v) -> v.advancedTo(finalLastToken));
      return;
        () -> tokenStore.extendClaim(getName(), segment.getSegmentId())
    );
    return;
  unitOfWork.resources().put(segmentIdResourceKey, segment.getSegmentId());
  unitOfWork.resources().put(lastTokenResourceKey, finalLastToken);
  processInUnitOfWork(batch, unitOfWork, segment);
  activeSegments.computeIfPresent(segment.getSegmentId(), (k, v) -> v.advancedTo(finalLastToken));
} catch (InterruptedException e) {
  logger.error(String.format("Event processor [%s] was interrupted. Shutting down.", getName()), e);
origin: org.axonframework/axon-messaging

/**
 * Indicates whether this segment can be merged with the given {@code other} segment.
 * <p>
 * Two segments can be merged when their mask is identical, and the only difference in SegmentID is in the first
 * 1-bit of their mask.
 *
 * @param other the Segment to verify mergeability for
 * @return {@code true} if the segments can be merged, otherwise {@code false}
 */
public boolean isMergeableWith(Segment other) {
  return this.mask == other.mask
      && mergeableSegmentId() == other.getSegmentId();
}
origin: org.axonframework/axon-core

/**
 * Indicates whether this segment can be merged with the given {@code other} segment.
 * <p>
 * Two segments can be merged when their mask is identical, and the only difference in SegmentID is in the first
 * 1-bit of their mask.
 *
 * @param other the Segment to verify mergeability for
 * @return {@code true} if the segments can be merged, otherwise {@code false}
 */
public boolean isMergeableWith(Segment other) {
  return this.mask == other.mask
      && mergeableSegmentId() == other.getSegmentId();
}
origin: org.axonframework/axon-core

@Override
public String toString() {
  return String.format("Segment[%d/%s]", getSegmentId(), getMask());
}
origin: org.axonframework/axon-messaging

@Override
public String toString() {
  return String.format("Segment[%d/%s]", getSegmentId(), getMask());
}
origin: org.axonframework/axon-core

private void checkSegmentCaughtUp(Segment segment, MessageStream<TrackedEventMessage<?>> eventStream) {
  if (!eventStream.hasNextAvailable()) {
    activeSegments.computeIfPresent(segment.getSegmentId(), (k, v) -> v.caughtUp());
  }
}
origin: org.axonframework/axon-messaging

private void checkSegmentCaughtUp(Segment segment, BlockingStream<TrackedEventMessage<?>> eventStream) {
  if (!eventStream.hasNextAvailable()) {
    activeSegments.computeIfPresent(segment.getSegmentId(), (k, v) -> v.caughtUp());
  }
}
origin: org.axonframework/axon-core

private void releaseToken(Segment segment) {
  try {
    transactionManager.executeInTransaction(() -> tokenStore.releaseClaim(getName(), segment.getSegmentId()));
  } catch (Exception e) {
    // whatever.
  }
}
origin: org.axonframework/axon-messaging

private void releaseToken(Segment segment) {
  try {
    transactionManager.executeInTransaction(() -> tokenStore.releaseClaim(getName(), segment.getSegmentId()));
  } catch (Exception e) {
    // Ignore exception
  }
}
origin: org.axonframework/axon-core

private MessageStream<TrackedEventMessage<?>> ensureEventStreamOpened(
    MessageStream<TrackedEventMessage<?>> eventStreamIn, Segment segment) {
  MessageStream<TrackedEventMessage<?>> eventStream = eventStreamIn;
  if (eventStream == null && state.get().isRunning()) {
    final TrackingToken trackingToken = transactionManager.fetchInTransaction(() -> tokenStore.fetchToken(getName(), segment.getSegmentId()));
    logger.info("Fetched token: {} for segment: {}", trackingToken, segment);
    eventStream = transactionManager.fetchInTransaction(
        () -> doOpenStream(trackingToken));
  }
  return eventStream;
}
origin: org.axonframework/axon-messaging

private BlockingStream<TrackedEventMessage<?>> ensureEventStreamOpened(
    BlockingStream<TrackedEventMessage<?>> eventStreamIn, Segment segment) {
  BlockingStream<TrackedEventMessage<?>> eventStream = eventStreamIn;
  if (eventStream == null && state.get().isRunning()) {
    final TrackingToken trackingToken = transactionManager.fetchInTransaction(
        () -> tokenStore.fetchToken(getName(), segment.getSegmentId())
    );
    logger.info("Fetched token: {} for segment: {}", trackingToken, segment);
    eventStream = transactionManager.fetchInTransaction(
        () -> doOpenStream(trackingToken));
  }
  return eventStream;
}
org.axonframework.eventhandlingSegmentgetSegmentId

Javadoc

Getter for the segment identifier.

Popular methods of Segment

  • getMask
    Getter for the segment mask.
  • matches
    Indicates whether the given value matches this segment. A value matches when the hashCode of a value
  • <init>
  • computeSegments
    Compute the Segment's from a given list of segmentId's.
  • isMergeableWith
    Indicates whether this segment can be merged with the given other segment. Two segments can be merge
  • mergeableSegmentId
    Returns the #getSegmentId() of the segment this one can be merged with
  • split
    Returns an array with two Segment. The first entry contains the original segmentId, with the newly

Popular in Java

  • Updating database using SQL prepared statement
  • getContentResolver (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • scheduleAtFixedRate (Timer)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JTextField (javax.swing)
  • 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