com.google.ipc.invalidation.ticl.InvalidationClientCore.BatchingTask Java Examples

The following examples show how to use com.google.ipc.invalidation.ticl.InvalidationClientCore.BatchingTask. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtocolHandler.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Sends a message to the server to request a client token.
 *
 * @param applicationClientId application-specific client id
 * @param nonce nonce for the request
 * @param debugString information to identify the caller
 */
void sendInitializeMessage(ApplicationClientIdP applicationClientId, Bytes nonce,
    BatchingTask batchingTask, String debugString) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  if (applicationClientId.getClientType() != clientType) {
    // This condition is not fatal, but it probably represents a bug somewhere if it occurs.
    logger.warning(
        "Client type in application id does not match constructor-provided type: %s vs %s",
        applicationClientId, clientType);
  }

  // Simply store the message in pendingInitializeMessage and send it when the batching task runs.
  InitializeMessage initializeMsg = InitializeMessage.create(clientType, nonce,
      applicationClientId, DigestSerializationType.BYTE_BASED);
  batcher.setInitializeMessage(initializeMsg);
  logger.info("Batching initialize message for client: %s, %s", debugString, initializeMsg);
  batchingTask.ensureScheduled(debugString);
}
 
Example #2
Source File: ProtocolHandler.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Sends an info message to the server with the performance counters supplied
 * in {@code performanceCounters} and the config supplies in
 * {@code configParams}.
 *
 * @param requestServerRegistrationSummary indicates whether to request the
 *        server's registration summary
 */
void sendInfoMessage(List<SimplePair<String, Integer>> performanceCounters,
    ClientConfigP clientConfig, boolean requestServerRegistrationSummary,
    BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");

  List<PropertyRecord> performanceCounterRecords =
      new ArrayList<PropertyRecord>(performanceCounters.size());
  for (SimplePair<String, Integer> counter : performanceCounters) {
    performanceCounterRecords.add(PropertyRecord.create(counter.first, counter.second));
  }
  InfoMessage infoMessage = InfoMessage.create(clientVersion, /* configParameter */ null,
      performanceCounterRecords, requestServerRegistrationSummary, clientConfig);

  // Simply store the message in pendingInfoMessage and send it when the batching task runs.
  batcher.setInfoMessage(infoMessage);
  batchingTask.ensureScheduled("Send-info");
}
 
Example #3
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Sends a message to the server to request a client token.
 *
 * @param applicationClientId application-specific client id
 * @param nonce nonce for the request
 * @param debugString information to identify the caller
 */
void sendInitializeMessage(ApplicationClientIdP applicationClientId, ByteString nonce,
    BatchingTask batchingTask, String debugString) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  if (applicationClientId.getClientType() != clientType) {
    // This condition is not fatal, but it probably represents a bug somewhere if it occurs.
    logger.warning(
        "Client type in application id does not match constructor-provided type: %s vs %s",
        applicationClientId, clientType);
  }

  // Simply store the message in pendingInitializeMessage and send it when the batching task runs.
  InitializeMessage initializeMsg = CommonProtos2.newInitializeMessage(clientType,
      applicationClientId, nonce, DigestSerializationType.BYTE_BASED);
  batcher.setInitializeMessage(initializeMsg);
  logger.info("Batching initialize message for client: %s, %s", debugString, initializeMsg);
  batchingTask.ensureScheduled(debugString);
}
 
Example #4
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Sends a message to the server to request a client token.
 *
 * @param applicationClientId application-specific client id
 * @param nonce nonce for the request
 * @param debugString information to identify the caller
 */
void sendInitializeMessage(ApplicationClientIdP applicationClientId, ByteString nonce,
    BatchingTask batchingTask, String debugString) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  if (applicationClientId.getClientType() != clientType) {
    // This condition is not fatal, but it probably represents a bug somewhere if it occurs.
    logger.warning(
        "Client type in application id does not match constructor-provided type: %s vs %s",
        applicationClientId, clientType);
  }

  // Simply store the message in pendingInitializeMessage and send it when the batching task runs.
  InitializeMessage initializeMsg = CommonProtos2.newInitializeMessage(clientType,
      applicationClientId, nonce, DigestSerializationType.BYTE_BASED);
  batcher.setInitializeMessage(initializeMsg);
  logger.info("Batching initialize message for client: %s, %s", debugString, initializeMsg);
  batchingTask.ensureScheduled(debugString);
}
 
Example #5
Source File: ProtocolHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Sends a registration request to the server.
 *
 * @param objectIds object ids on which to (un)register
 * @param regOpType whether to register or unregister
 */
void sendRegistrations(Collection<ObjectIdP> objectIds, Integer regOpType,
    BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  for (ObjectIdP objectId : objectIds) {
    batcher.addRegistration(objectId, regOpType);
  }
  batchingTask.ensureScheduled("Send-registrations");
}
 
Example #6
Source File: ProtocolHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Sends an acknowledgement for {@code invalidation} to the server. */
void sendInvalidationAck(InvalidationP invalidation, BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  // We could summarize acks when there are suppressing invalidations - we don't since it is
  // unlikely to be too beneficial here.
  logger.fine("Sending ack for invalidation %s", invalidation);
  batcher.addAck(invalidation);
  batchingTask.ensureScheduled("Send-Ack");
}
 
Example #7
Source File: ProtocolHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Sends a single registration subtree to the server.
 *
 * @param regSubtree subtree to send
 */
void sendRegistrationSyncSubtree(RegistrationSubtree regSubtree, BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  batcher.addRegSubtree(regSubtree);
  logger.info("Adding subtree: %s", regSubtree);
  batchingTask.ensureScheduled("Send-reg-sync");
}
 
Example #8
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sends an info message to the server with the performance counters supplied
 * in {@code performanceCounters} and the config supplies in
 * {@code configParams}.
 *
 * @param requestServerRegistrationSummary indicates whether to request the
 *        server's registration summary
 */
void sendInfoMessage(List<SimplePair<String, Integer>> performanceCounters,
    ClientConfigP clientConfig, boolean requestServerRegistrationSummary,
    BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  InfoMessage.Builder infoMessage = InfoMessage.newBuilder()
      .setClientVersion(clientVersion);

  // Add configuration parameters.
  if (clientConfig != null) {
    infoMessage.setClientConfig(clientConfig);
  }

  // Add performance counters.
  for (SimplePair<String, Integer> performanceCounter : performanceCounters) {
    PropertyRecord counter =
        CommonProtos2.newPropertyRecord(performanceCounter.first, performanceCounter.second);
    infoMessage.addPerformanceCounter(counter);
  }

  // Indicate whether we want the server's registration summary sent back.
  infoMessage.setServerRegistrationSummaryRequested(requestServerRegistrationSummary);

  // Simply store the message in pendingInfoMessage and send it when the batching task runs.
  batcher.setInfoMessage(infoMessage.build());
  batchingTask.ensureScheduled("Send-info");
}
 
Example #9
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sends a registration request to the server.
 *
 * @param objectIds object ids on which to (un)register
 * @param regOpType whether to register or unregister
 */
void sendRegistrations(Collection<ObjectIdP> objectIds, RegistrationP.OpType regOpType,
    BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  for (ObjectIdP objectId : objectIds) {
    batcher.addRegistration(objectId, regOpType);
  }
  batchingTask.ensureScheduled("Send-registrations");
}
 
Example #10
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Sends an acknowledgement for {@code invalidation} to the server. */
void sendInvalidationAck(InvalidationP invalidation, BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  // We could do squelching - we don't since it is unlikely to be too beneficial here.
  logger.fine("Sending ack for invalidation %s", invalidation);
  batcher.addAck(invalidation);
  batchingTask.ensureScheduled("Send-Ack");
}
 
Example #11
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sends a single registration subtree to the server.
 *
 * @param regSubtree subtree to send
 */
void sendRegistrationSyncSubtree(RegistrationSubtree regSubtree, BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  batcher.addRegSubtree(regSubtree);
  logger.info("Adding subtree: %s", regSubtree);
  batchingTask.ensureScheduled("Send-reg-sync");
}
 
Example #12
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sends an info message to the server with the performance counters supplied
 * in {@code performanceCounters} and the config supplies in
 * {@code configParams}.
 *
 * @param requestServerRegistrationSummary indicates whether to request the
 *        server's registration summary
 */
void sendInfoMessage(List<SimplePair<String, Integer>> performanceCounters,
    ClientConfigP clientConfig, boolean requestServerRegistrationSummary,
    BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  InfoMessage.Builder infoMessage = InfoMessage.newBuilder()
      .setClientVersion(clientVersion);

  // Add configuration parameters.
  if (clientConfig != null) {
    infoMessage.setClientConfig(clientConfig);
  }

  // Add performance counters.
  for (SimplePair<String, Integer> performanceCounter : performanceCounters) {
    PropertyRecord counter =
        CommonProtos2.newPropertyRecord(performanceCounter.first, performanceCounter.second);
    infoMessage.addPerformanceCounter(counter);
  }

  // Indicate whether we want the server's registration summary sent back.
  infoMessage.setServerRegistrationSummaryRequested(requestServerRegistrationSummary);

  // Simply store the message in pendingInfoMessage and send it when the batching task runs.
  batcher.setInfoMessage(infoMessage.build());
  batchingTask.ensureScheduled("Send-info");
}
 
Example #13
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sends a registration request to the server.
 *
 * @param objectIds object ids on which to (un)register
 * @param regOpType whether to register or unregister
 */
void sendRegistrations(Collection<ObjectIdP> objectIds, RegistrationP.OpType regOpType,
    BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  for (ObjectIdP objectId : objectIds) {
    batcher.addRegistration(objectId, regOpType);
  }
  batchingTask.ensureScheduled("Send-registrations");
}
 
Example #14
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Sends an acknowledgement for {@code invalidation} to the server. */
void sendInvalidationAck(InvalidationP invalidation, BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  // We could do squelching - we don't since it is unlikely to be too beneficial here.
  logger.fine("Sending ack for invalidation %s", invalidation);
  batcher.addAck(invalidation);
  batchingTask.ensureScheduled("Send-Ack");
}
 
Example #15
Source File: ProtocolHandler.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sends a single registration subtree to the server.
 *
 * @param regSubtree subtree to send
 */
void sendRegistrationSyncSubtree(RegistrationSubtree regSubtree, BatchingTask batchingTask) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  batcher.addRegSubtree(regSubtree);
  logger.info("Adding subtree: %s", regSubtree);
  batchingTask.ensureScheduled("Send-reg-sync");
}