当前位置: 首页>>代码示例>>Java>>正文


Java ReceivedMessageType类代码示例

本文整理汇总了Java中com.google.ipc.invalidation.ticl.Statistics.ReceivedMessageType的典型用法代码示例。如果您正苦于以下问题:Java ReceivedMessageType类的具体用法?Java ReceivedMessageType怎么用?Java ReceivedMessageType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ReceivedMessageType类属于com.google.ipc.invalidation.ticl.Statistics包,在下文中一共展示了ReceivedMessageType类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleInvalidations

import com.google.ipc.invalidation.ticl.Statistics.ReceivedMessageType; //导入依赖的package包/类
/** Handles incoming {@code invalidations}. */
private void handleInvalidations(Collection<InvalidationP> invalidations) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");

  for (InvalidationP invalidation : invalidations) {
    AckHandle ackHandle = AckHandle.newInstance(AckHandleP.create(invalidation).toByteArray());
    if (ackCache.isAcked(invalidation)) {
      // If the ack cache indicates that the client has already acked a restarted invalidation
      // with an equal or greater version, then the TICL can simply acknowledge it immediately
      // rather than delivering it to the listener.
      logger.info("Stale invalidation {0}, not delivering", invalidation);
      acknowledge(ackHandle);
      statistics.recordReceivedMessage(ReceivedMessageType.STALE_INVALIDATION);
    } else if (CommonProtos.isAllObjectId(invalidation.getObjectId())) {
      logger.info("Issuing invalidate all");
      listener.invalidateAll(InvalidationClientCore.this, ackHandle);
    } else {
      // Regular object. Could be unknown version or not.
      Invalidation inv = ProtoWrapperConverter.convertFromInvalidationProto(invalidation);

      boolean isSuppressed = invalidation.getIsTrickleRestart();
      logger.info("Issuing invalidate (known-version = %s, is-trickle-restart = %s): %s",
          invalidation.getIsKnownVersion(), isSuppressed, inv);

      // Issue invalidate if the invalidation had a known version AND either no suppression has
      // occurred or the client allows suppression.
      if (invalidation.getIsKnownVersion() &&
          (!isSuppressed || InvalidationClientCore.this.config.getAllowSuppression())) {
        listener.invalidate(InvalidationClientCore.this, inv, ackHandle);
      } else {
        // Otherwise issue invalidateUnknownVersion.
        listener.invalidateUnknownVersion(InvalidationClientCore.this, inv.getObjectId(),
            ackHandle);
      }
    }
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:38,代码来源:InvalidationClientCore.java

示例2: handleIncomingMessage

import com.google.ipc.invalidation.ticl.Statistics.ReceivedMessageType; //导入依赖的package包/类
/**
 * Handles a message from the server. If the message can be processed (i.e., is valid, is
 * of the right version, and is not a silence message), returns a {@link ParsedMessage}
 * representing it. Otherwise, returns {@code null}.
 * <p>
 * This class intercepts and processes silence messages. In this case, it will discard any other
 * data in the message.
 * <p>
 * Note that this method does <b>not</b> check the session token of any message.
 */
ParsedMessage handleIncomingMessage(byte[] incomingMessage) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  ServerToClientMessage message;
  try {
    message = ServerToClientMessage.parseFrom(incomingMessage);
  } catch (ValidationException exception) {
    statistics.recordError(ClientErrorType.INCOMING_MESSAGE_FAILURE);
    logger.warning("Incoming message is invalid: %s", Bytes.toLazyCompactString(incomingMessage));
    return null;
  }

  // Check the version of the message.
  if (message.getHeader().getProtocolVersion().getVersion().getMajorVersion() !=
      ClientConstants.PROTOCOL_MAJOR_VERSION) {
    statistics.recordError(ClientErrorType.PROTOCOL_VERSION_FAILURE);
    logger.severe("Dropping message with incompatible version: %s", message);
    return null;
  }

  // Check if it is a ConfigChangeMessage which indicates that messages should no longer be
  // sent for a certain duration. Perform this check before the token is even checked.
  if (message.hasConfigChangeMessage()) {
    ConfigChangeMessage configChangeMsg = message.getConfigChangeMessage();
    statistics.recordReceivedMessage(ReceivedMessageType.CONFIG_CHANGE);
    if (configChangeMsg.hasNextMessageDelayMs()) {  // Validator has ensured that it is positive.
      nextMessageSendTimeMs =
          internalScheduler.getCurrentTimeMs() + configChangeMsg.getNextMessageDelayMs();
    }
    return null;  // Ignore all other messages in the envelope.
  }

  lastKnownServerTimeMs = Math.max(lastKnownServerTimeMs, message.getHeader().getServerTimeMs());
  return new ParsedMessage(message);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:45,代码来源:ProtocolHandler.java

示例3: handleIncomingMessage

import com.google.ipc.invalidation.ticl.Statistics.ReceivedMessageType; //导入依赖的package包/类
/**
 * Handles an {@code incomingMessage} from the data center. If it is valid and addressed to
 * this client, dispatches to methods to handle sub-parts of the message; if not, drops the
 * message.
 */
void handleIncomingMessage(byte[] incomingMessage) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  statistics.recordReceivedMessage(ReceivedMessageType.TOTAL);
  ParsedMessage parsedMessage = protocolHandler.handleIncomingMessage(incomingMessage);
  if (parsedMessage == null) {
    // Invalid message.
    return;
  }

  // Ensure we have either a matching token or a matching nonce.
  if (!validateToken(parsedMessage)) {
    return;
  }

  // Handle a token-control message, if present.
  if (parsedMessage.tokenControlMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.TOKEN_CONTROL);
    handleTokenChanged(parsedMessage.header.token,
        parsedMessage.tokenControlMessage.hasNewToken() ?
            parsedMessage.tokenControlMessage.getNewToken() : null);
  }

  // We might have lost our token or failed to acquire one. Ensure that we do not proceed in
  // either case.
  if (clientToken == null) {
    return;
  }

  // First, handle the message header.
  handleIncomingHeader(parsedMessage.header);

  // Then, handle any work remaining in the message.
  if (parsedMessage.invalidationMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.INVALIDATION);
    handleInvalidations(parsedMessage.invalidationMessage.getInvalidation());
  }
  if (parsedMessage.registrationStatusMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.REGISTRATION_STATUS);
    handleRegistrationStatus(parsedMessage.registrationStatusMessage.getRegistrationStatus());
  }
  if (parsedMessage.registrationSyncRequestMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.REGISTRATION_SYNC_REQUEST);
    handleRegistrationSyncRequest();
  }
  if (parsedMessage.infoRequestMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.INFO_REQUEST);
    handleInfoMessage(parsedMessage.infoRequestMessage.getInfoType());
  }
  if (parsedMessage.errorMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.ERROR);
    handleErrorMessage(parsedMessage.header, parsedMessage.errorMessage.getCode(),
        parsedMessage.errorMessage.getDescription());
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:60,代码来源:InvalidationClientCore.java

示例4: handleIncomingMessage

import com.google.ipc.invalidation.ticl.Statistics.ReceivedMessageType; //导入依赖的package包/类
/**
 * Handles an {@code incomingMessage} from the data center. If it is valid and addressed to
 * this client, dispatches to methods to handle sub-parts of the message; if not, drops the
 * message.
 */
void handleIncomingMessage(byte[] incomingMessage) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  statistics.recordReceivedMessage(ReceivedMessageType.TOTAL);
  ParsedMessage parsedMessage = protocolHandler.handleIncomingMessage(incomingMessage);
  if (parsedMessage == null) {
    // Invalid message.
    return;
  }

  // Ensure we have either a matching token or a matching nonce.
  if (!validateToken(parsedMessage)) {
    return;
  }

  // Handle a token-control message, if present.
  if (parsedMessage.tokenControlMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.TOKEN_CONTROL);
    handleTokenChanged(parsedMessage.header.token,
        parsedMessage.tokenControlMessage.hasNewToken() ?
            parsedMessage.tokenControlMessage.getNewToken() : null);
  }

  // We might have lost our token or failed to acquire one. Ensure that we do not proceed in
  // either case.
  if (clientToken == null) {
    return;
  }

  // First, handle the message header.
  handleIncomingHeader(parsedMessage.header);

  // Then, handle any work remaining in the message.
  if (parsedMessage.invalidationMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.INVALIDATION);
    handleInvalidations(parsedMessage.invalidationMessage.getInvalidationList());
  }
  if (parsedMessage.registrationStatusMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.REGISTRATION_STATUS);
    handleRegistrationStatus(parsedMessage.registrationStatusMessage.getRegistrationStatusList());
  }
  if (parsedMessage.registrationSyncRequestMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.REGISTRATION_SYNC_REQUEST);
    handleRegistrationSyncRequest();
  }
  if (parsedMessage.infoRequestMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.INFO_REQUEST);
    handleInfoMessage(parsedMessage.infoRequestMessage.getInfoTypeList());
  }
  if (parsedMessage.errorMessage != null) {
    statistics.recordReceivedMessage(ReceivedMessageType.ERROR);
    handleErrorMessage(parsedMessage.header, parsedMessage.errorMessage.getCode(),
        parsedMessage.errorMessage.getDescription());
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:60,代码来源:InvalidationClientCore.java

示例5: handleIncomingMessage

import com.google.ipc.invalidation.ticl.Statistics.ReceivedMessageType; //导入依赖的package包/类
/**
 * Handles a message from the server. If the message can be processed (i.e., is valid, is
 * of the right version, and is not a silence message), returns a {@link ParsedMessage}
 * representing it. Otherwise, returns {@code null}.
 * <p>
 * This class intercepts and processes silence messages. In this case, it will discard any other
 * data in the message.
 * <p>
 * Note that this method does <b>not</b> check the session token of any message.
 */
ParsedMessage handleIncomingMessage(byte[] incomingMessage) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  ServerToClientMessage message;
  try {
    message = ServerToClientMessage.parseFrom(incomingMessage);
  } catch (InvalidProtocolBufferException exception) {
    logger.warning("Incoming message is unparseable: %s",
        CommonProtoStrings2.toLazyCompactString(incomingMessage));
    return null;
  }

  // Validate the message. If this passes, we can blindly assume valid messages from here on.
  logger.fine("Incoming message: %s", message);
  if (!msgValidator.isValid(message)) {
    statistics.recordError(ClientErrorType.INCOMING_MESSAGE_FAILURE);
    logger.severe("Received invalid message: %s", message);
    return null;
  }

  // Check the version of the message.
  if (message.getHeader().getProtocolVersion().getVersion().getMajorVersion() !=
      CommonInvalidationConstants2.PROTOCOL_MAJOR_VERSION) {
    statistics.recordError(ClientErrorType.PROTOCOL_VERSION_FAILURE);
    logger.severe("Dropping message with incompatible version: %s", message);
    return null;
  }

  // Check if it is a ConfigChangeMessage which indicates that messages should no longer be
  // sent for a certain duration. Perform this check before the token is even checked.
  if (message.hasConfigChangeMessage()) {
    ConfigChangeMessage configChangeMsg = message.getConfigChangeMessage();
    statistics.recordReceivedMessage(ReceivedMessageType.CONFIG_CHANGE);
    if (configChangeMsg.hasNextMessageDelayMs()) {  // Validator has ensured that it is positive.
      nextMessageSendTimeMs =
          internalScheduler.getCurrentTimeMs() + configChangeMsg.getNextMessageDelayMs();
    }
    return null;  // Ignore all other messages in the envelope.
  }

  lastKnownServerTimeMs = Math.max(lastKnownServerTimeMs, message.getHeader().getServerTimeMs());
  return new ParsedMessage(message);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:53,代码来源:ProtocolHandler.java


注:本文中的com.google.ipc.invalidation.ticl.Statistics.ReceivedMessageType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。