Codota Logo
GenericTokenEntry.<init>
Code IndexAdd Codota to your IDE (free)

How to use
org.axonframework.eventhandling.tokenstore.GenericTokenEntry
constructor

Best Java code snippets using org.axonframework.eventhandling.tokenstore.GenericTokenEntry.<init> (Showing top 14 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
LocalDateTime l =
  • Codota Iconnew LocalDateTime()
  • Codota IconLocalDateTime.now()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseLocalDateTime(text)
  • Smart code suggestions by Codota
}
origin: AxonFramework/AxonFramework

/**
 * Convert given {@code resultSet} to an {@link AbstractTokenEntry}. The result set contains a single token entry.
 *
 * @param resultSet the result set of a prior select statement containing a single token entry
 * @return an token entry with data extracted from the result set
 *
 * @throws SQLException if the result set cannot be converted to an entry
 */
protected AbstractTokenEntry<?> readTokenEntry(ResultSet resultSet) throws SQLException {
  return new GenericTokenEntry<>(readSerializedData(resultSet, schema.tokenColumn()),
                  resultSet.getString(schema.tokenTypeColumn()),
                  resultSet.getString(schema.timestampColumn()),
                  resultSet.getString(schema.ownerColum()),
                  resultSet.getString(schema.processorNameColumn()),
                  resultSet.getInt(schema.segmentColumn()), contentType);
}
origin: AxonFramework/AxonFramework

/**
 * Inserts a new token entry via the given updatable {@code resultSet}.
 *
 * @param resultSet     the updatable result set to add the entry to
 * @param token         the token of the entry to insert
 * @param processorName the name of the processor to insert a token for
 * @param segment       the segment of the processor to insert a token for
 * @return the tracking token of the inserted entry
 *
 * @throws SQLException when an exception occurs while inserting a token entry
 */
protected TrackingToken insertTokenEntry(ResultSet resultSet, TrackingToken token, String processorName,
                     int segment) throws SQLException {
  AbstractTokenEntry<?> entry = new GenericTokenEntry<>(token, serializer, contentType, processorName, segment);
  entry.claim(nodeId, claimTimeout);
  resultSet.moveToInsertRow();
  resultSet.updateObject(schema.tokenColumn(), token == null ? null : entry.getSerializedToken().getData());
  resultSet.updateString(schema.tokenTypeColumn(),
              token == null ? null : entry.getSerializedToken().getType().getName());
  resultSet.updateString(schema.timestampColumn(), entry.timestampAsString());
  resultSet.updateString(schema.ownerColum(), entry.getOwner());
  resultSet.updateString(schema.processorNameColumn(), processorName);
  resultSet.updateInt(schema.segmentColumn(), segment);
  resultSet.insertRow();
  return token;
}
origin: org.axonframework/axon-mongo

@Override
public void initializeTokenSegments(String processorName, int segmentCount, TrackingToken initialToken) throws UnableToClaimTokenException {
  if (fetchSegments(processorName).length > 0) {
    throw new UnableToClaimTokenException("Unable to initialize segments. Some tokens were already present for the given processor.");
  }
  List<Document> entries = IntStream.range(0, segmentCount)
                   .mapToObj(segment -> new GenericTokenEntry<>(initialToken, serializer,
                                          contentType, processorName,
                                          segment))
                   .map(this::tokenEntryToDocument)
                   .collect(Collectors.toList());
  mongoTemplate.trackingTokensCollection()
         .insertMany(entries, new InsertManyOptions().ordered(false));
}
origin: org.axonframework.extensions.mongo/axon-mongo

@Override
public void initializeTokenSegments(String processorName,
                  int segmentCount,
                  TrackingToken initialToken) throws UnableToClaimTokenException {
  if (fetchSegments(processorName).length > 0) {
    throw new UnableToClaimTokenException(
        "Unable to initialize segments. Some tokens were already present for the given processor."
    );
  }
  List<Document> entries = IntStream.range(0, segmentCount)
                   .mapToObj(segment -> new GenericTokenEntry<>(initialToken, serializer,
                                          contentType, processorName,
                                          segment))
                   .map(this::tokenEntryToDocument)
                   .collect(Collectors.toList());
  mongoTemplate.trackingTokensCollection()
         .insertMany(entries, new InsertManyOptions().ordered(false));
}
origin: org.axonframework/axon-core

/**
 * Convert given {@code resultSet} to an {@link AbstractTokenEntry}. The result set contains a single token entry.
 *
 * @param resultSet the result set of a prior select statement containing a single token entry
 * @return an token entry with data extracted from the result set
 * @throws SQLException if the result set cannot be converted to an entry
 */
protected AbstractTokenEntry<?> readTokenEntry(ResultSet resultSet) throws SQLException {
  return new GenericTokenEntry<>(readSerializedData(resultSet, schema.tokenColumn()),
                  resultSet.getString(schema.tokenTypeColumn()),
                  resultSet.getString(schema.timestampColumn()),
                  resultSet.getString(schema.ownerColum()),
                  resultSet.getString(schema.processorNameColumn()),
                  resultSet.getInt(schema.segmentColumn()), contentType);
}
origin: org.axonframework/axon-messaging

/**
 * Convert given {@code resultSet} to an {@link AbstractTokenEntry}. The result set contains a single token entry.
 *
 * @param resultSet the result set of a prior select statement containing a single token entry
 * @return an token entry with data extracted from the result set
 *
 * @throws SQLException if the result set cannot be converted to an entry
 */
protected AbstractTokenEntry<?> readTokenEntry(ResultSet resultSet) throws SQLException {
  return new GenericTokenEntry<>(readSerializedData(resultSet, schema.tokenColumn()),
                  resultSet.getString(schema.tokenTypeColumn()),
                  resultSet.getString(schema.timestampColumn()),
                  resultSet.getString(schema.ownerColum()),
                  resultSet.getString(schema.processorNameColumn()),
                  resultSet.getInt(schema.segmentColumn()), contentType);
}
origin: org.axonframework/axon-mongo

private AbstractTokenEntry<?> documentToTokenEntry(Document document) {
  return new GenericTokenEntry<>(
      readSerializedData(document),
      document.getString("tokenType"),
      Instant.ofEpochMilli(document.getLong("timestamp")).toString(),
      document.getString("owner"),
      document.getString("processorName"),
      document.getInteger("segment"),
      contentType);
}
origin: org.axonframework.extensions.mongo/axon-mongo

private AbstractTokenEntry<?> documentToTokenEntry(Document document) {
  return new GenericTokenEntry<>(
      readSerializedData(document),
      document.getString("tokenType"),
      Instant.ofEpochMilli(document.getLong("timestamp")).toString(),
      document.getString("owner"),
      document.getString("processorName"),
      document.getInteger("segment"),
      contentType);
}
origin: org.axonframework/axon-mongo

private void updateOrInsertTokenEntry(TrackingToken token, String processorName, int segment) {
  AbstractTokenEntry<?> tokenEntry = new GenericTokenEntry<>(token,
                                serializer,
                                contentType,
                                processorName,
                                segment);
  tokenEntry.claim(nodeId, claimTimeout);
  Bson update = combine(set("owner", nodeId),
             set("timestamp", tokenEntry.timestamp().toEpochMilli()),
             set("token", tokenEntry.getSerializedToken().getData()),
             set("tokenType", tokenEntry.getSerializedToken().getType().getName()));
  UpdateResult updateResult = mongoTemplate.trackingTokensCollection()
                       .updateOne(claimableTokenEntryFilter(processorName, segment), update);
  if (updateResult.getModifiedCount() == 0) {
    try {
      mongoTemplate.trackingTokensCollection()
             .insertOne(tokenEntryToDocument(tokenEntry));
    } catch (MongoWriteException exception) {
      if (ErrorCategory.fromErrorCode(exception.getError().getCode()) == ErrorCategory.DUPLICATE_KEY) {
        throw new UnableToClaimTokenException(format("Unable to claim token '%s[%s]'",
                               processorName,
                               segment));
      }
    }
  }
}
origin: org.axonframework.extensions.mongo/axon-mongo

private void updateOrInsertTokenEntry(TrackingToken token, String processorName, int segment) {
  AbstractTokenEntry<?> tokenEntry = new GenericTokenEntry<>(token,
                                serializer,
                                contentType,
                                processorName,
                                segment);
  tokenEntry.claim(nodeId, claimTimeout);
  Bson update = combine(set("owner", nodeId),
             set("timestamp", tokenEntry.timestamp().toEpochMilli()),
             set("token", tokenEntry.getSerializedToken().getData()),
             set("tokenType", tokenEntry.getSerializedToken().getType().getName()));
  UpdateResult updateResult = mongoTemplate.trackingTokensCollection()
                       .updateOne(claimableTokenEntryFilter(processorName, segment), update);
  if (updateResult.getModifiedCount() == 0) {
    try {
      mongoTemplate.trackingTokensCollection()
             .insertOne(tokenEntryToDocument(tokenEntry));
    } catch (MongoWriteException exception) {
      if (ErrorCategory.fromErrorCode(exception.getError().getCode()) == ErrorCategory.DUPLICATE_KEY) {
        throw new UnableToClaimTokenException(format("Unable to claim token '%s[%s]'",
                               processorName,
                               segment));
      }
    }
  }
}
origin: org.axonframework/axon-mongo

private AbstractTokenEntry<?> loadOrInsertTokenEntry(String processorName, int segment) {
  Document document = mongoTemplate.trackingTokensCollection()
                   .findOneAndUpdate(claimableTokenEntryFilter(processorName, segment),
                            combine(set("owner", nodeId),
                                set("timestamp", clock.millis())),
                            new FindOneAndUpdateOptions()
                                .returnDocument(ReturnDocument.AFTER));
  if (document == null) {
    try {
      AbstractTokenEntry<?> tokenEntry = new GenericTokenEntry<>(null,
                                    serializer,
                                    contentType,
                                    processorName,
                                    segment);
      tokenEntry.claim(nodeId, claimTimeout);
      mongoTemplate.trackingTokensCollection()
             .insertOne(tokenEntryToDocument(tokenEntry));
      return tokenEntry;
    } catch (MongoWriteException exception) {
      if (ErrorCategory.fromErrorCode(exception.getError().getCode()) == ErrorCategory.DUPLICATE_KEY) {
        throw new UnableToClaimTokenException(format("Unable to claim token '%s[%s]'",
                               processorName,
                               segment));
      }
    }
  }
  return documentToTokenEntry(document);
}
origin: org.axonframework.extensions.mongo/axon-mongo

private AbstractTokenEntry<?> loadOrInsertTokenEntry(String processorName, int segment) {
  Document document = mongoTemplate.trackingTokensCollection()
                   .findOneAndUpdate(claimableTokenEntryFilter(processorName, segment),
                            combine(set("owner", nodeId),
                                set("timestamp", clock.millis())),
                            new FindOneAndUpdateOptions()
                                .returnDocument(ReturnDocument.AFTER));
  if (document == null) {
    try {
      AbstractTokenEntry<?> tokenEntry = new GenericTokenEntry<>(null,
                                    serializer,
                                    contentType,
                                    processorName,
                                    segment);
      tokenEntry.claim(nodeId, claimTimeout);
      mongoTemplate.trackingTokensCollection()
             .insertOne(tokenEntryToDocument(tokenEntry));
      return tokenEntry;
    } catch (MongoWriteException exception) {
      if (ErrorCategory.fromErrorCode(exception.getError().getCode()) == ErrorCategory.DUPLICATE_KEY) {
        throw new UnableToClaimTokenException(format("Unable to claim token '%s[%s]'",
                               processorName,
                               segment));
      }
    }
  }
  return documentToTokenEntry(document);
}
origin: org.axonframework/axon-core

/**
 * Inserts a new token entry via the given updatable {@code resultSet}.
 *
 * @param resultSet     the updatable result set to add the entry to
 * @param token         the token of the entry to insert
 * @param processorName the name of the processor to insert a token for
 * @param segment       the segment of the processor to insert a token for
 * @return the tracking token of the inserted entry
 * @throws SQLException when an exception occurs while inserting a token entry
 */
protected TrackingToken insertTokenEntry(ResultSet resultSet, TrackingToken token, String processorName,
                     int segment) throws SQLException {
  AbstractTokenEntry<?> entry = new GenericTokenEntry<>(token, serializer, contentType, processorName, segment);
  entry.claim(nodeId, claimTimeout);
  resultSet.moveToInsertRow();
  resultSet.updateObject(schema.tokenColumn(), token == null ? null : entry.getSerializedToken().getData());
  resultSet.updateString(schema.tokenTypeColumn(),
              token == null ? null : entry.getSerializedToken().getType().getName());
  resultSet.updateString(schema.timestampColumn(), entry.timestampAsString());
  resultSet.updateString(schema.ownerColum(), entry.getOwner());
  resultSet.updateString(schema.processorNameColumn(), processorName);
  resultSet.updateInt(schema.segmentColumn(), segment);
  resultSet.insertRow();
  return token;
}
origin: org.axonframework/axon-messaging

/**
 * Inserts a new token entry via the given updatable {@code resultSet}.
 *
 * @param resultSet     the updatable result set to add the entry to
 * @param token         the token of the entry to insert
 * @param processorName the name of the processor to insert a token for
 * @param segment       the segment of the processor to insert a token for
 * @return the tracking token of the inserted entry
 *
 * @throws SQLException when an exception occurs while inserting a token entry
 */
protected TrackingToken insertTokenEntry(ResultSet resultSet, TrackingToken token, String processorName,
                     int segment) throws SQLException {
  AbstractTokenEntry<?> entry = new GenericTokenEntry<>(token, serializer, contentType, processorName, segment);
  entry.claim(nodeId, claimTimeout);
  resultSet.moveToInsertRow();
  resultSet.updateObject(schema.tokenColumn(), token == null ? null : entry.getSerializedToken().getData());
  resultSet.updateString(schema.tokenTypeColumn(),
              token == null ? null : entry.getSerializedToken().getType().getName());
  resultSet.updateString(schema.timestampColumn(), entry.timestampAsString());
  resultSet.updateString(schema.ownerColum(), entry.getOwner());
  resultSet.updateString(schema.processorNameColumn(), processorName);
  resultSet.updateInt(schema.segmentColumn(), segment);
  resultSet.insertRow();
  return token;
}
org.axonframework.eventhandling.tokenstoreGenericTokenEntry<init>

Javadoc

Initializes a token entry from existing data.

Popular methods of GenericTokenEntry

  • updateToken

Popular in Java

  • Start an intent from android
  • getSharedPreferences (Context)
  • getExternalFilesDir (Context)
  • startActivity (Activity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
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