com.google.ipc.invalidation.ticl.TiclExponentialBackoffDelayGenerator Java Examples

The following examples show how to use com.google.ipc.invalidation.ticl.TiclExponentialBackoffDelayGenerator. 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: AndroidListenerState.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/** Initializes state from proto. */
AndroidListenerState(int initialMaxDelayMs, int maxDelayFactor,
    AndroidListenerProtocol.AndroidListenerState state) {
  desiredRegistrations = new HashSet<ObjectId>();
  for (ObjectIdP objectIdProto : state.getRegistration()) {
    desiredRegistrations.add(ProtoWrapperConverter.convertFromObjectIdProto(objectIdProto));
  }
  for (RetryRegistrationState retryState : state.getRetryRegistrationState()) {
    ObjectIdP objectIdP = retryState.getNullableObjectId();
    if (objectIdP == null) {
      continue;
    }
    ObjectId objectId = ProtoWrapperConverter.convertFromObjectIdProto(objectIdP);
    delayGenerators.put(objectId, new TiclExponentialBackoffDelayGenerator(random,
        initialMaxDelayMs, maxDelayFactor, retryState.getExponentialBackoffState()));
  }
  for (ScheduledRegistrationRetry registrationRetry : state.getRegistrationRetry()) {
    registrationRetries.put(registrationRetry.getExecuteTimeMs(), registrationRetry.getCommand());
  }
  clientId = state.getClientId();
  requestCodeSeqNum = state.getRequestCodeSeqNum();
  isDirty = false;
  this.initialMaxDelayMs = initialMaxDelayMs;
  this.maxDelayFactor = maxDelayFactor;
}
 
Example #2
Source File: AndroidListenerState.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Initializes state from proto. */
AndroidListenerState(int initialMaxDelayMs, int maxDelayFactor,
    AndroidListenerProtocol.AndroidListenerState state) {
  desiredRegistrations = new HashSet<ObjectId>();
  for (ObjectIdP objectIdProto : state.getRegistrationList()) {
    desiredRegistrations.add(ProtoConverter.convertFromObjectIdProto(objectIdProto));
  }
  for (RetryRegistrationState retryState : state.getRetryRegistrationStateList()) {
    ObjectId objectId = ProtoConverter.convertFromObjectIdProto(retryState.getObjectId());
    delayGenerators.put(objectId, new TiclExponentialBackoffDelayGenerator(random,
        initialMaxDelayMs, maxDelayFactor, retryState.getExponentialBackoffState()));
  }
  clientId = state.getClientId();
  requestCodeSeqNum = state.getRequestCodeSeqNum();
  isDirty = false;
  this.initialMaxDelayMs = initialMaxDelayMs;
  this.maxDelayFactor = maxDelayFactor;
}
 
Example #3
Source File: AndroidListenerProtos.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Creates proto for {@link AndroidListener} state. */
static AndroidListenerState newAndroidListenerState(ByteString clientId, int requestCodeSeqNum,
    Map<ObjectId, TiclExponentialBackoffDelayGenerator> delayGenerators,
    Iterable<ObjectId> desiredRegistrations) {
  AndroidListenerState.Builder builder = AndroidListenerState.newBuilder()
      .setClientId(clientId)
      .setRequestCodeSeqNum(requestCodeSeqNum);
  for (ObjectId objectId : desiredRegistrations) {
    builder.addRegistration(ProtoConverter.convertToObjectIdProto(objectId));
  }
  for (Entry<ObjectId, TiclExponentialBackoffDelayGenerator> entry : delayGenerators.entrySet()) {
    builder.addRetryRegistrationState(
        newRetryRegistrationState(entry.getKey(), entry.getValue()));
  }
  return builder.build();
}
 
Example #4
Source File: AndroidListenerState.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Initializes state from proto. */
AndroidListenerState(int initialMaxDelayMs, int maxDelayFactor,
    AndroidListenerProtocol.AndroidListenerState state) {
  desiredRegistrations = new HashSet<ObjectId>();
  for (ObjectIdP objectIdProto : state.getRegistrationList()) {
    desiredRegistrations.add(ProtoConverter.convertFromObjectIdProto(objectIdProto));
  }
  for (RetryRegistrationState retryState : state.getRetryRegistrationStateList()) {
    ObjectId objectId = ProtoConverter.convertFromObjectIdProto(retryState.getObjectId());
    delayGenerators.put(objectId, new TiclExponentialBackoffDelayGenerator(random,
        initialMaxDelayMs, maxDelayFactor, retryState.getExponentialBackoffState()));
  }
  clientId = state.getClientId();
  requestCodeSeqNum = state.getRequestCodeSeqNum();
  isDirty = false;
  this.initialMaxDelayMs = initialMaxDelayMs;
  this.maxDelayFactor = maxDelayFactor;
}
 
Example #5
Source File: AndroidListenerProtos.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Creates proto for {@link AndroidListener} state. */
static AndroidListenerState newAndroidListenerState(ByteString clientId, int requestCodeSeqNum,
    Map<ObjectId, TiclExponentialBackoffDelayGenerator> delayGenerators,
    Iterable<ObjectId> desiredRegistrations) {
  AndroidListenerState.Builder builder = AndroidListenerState.newBuilder()
      .setClientId(clientId)
      .setRequestCodeSeqNum(requestCodeSeqNum);
  for (ObjectId objectId : desiredRegistrations) {
    builder.addRegistration(ProtoConverter.convertToObjectIdProto(objectId));
  }
  for (Entry<ObjectId, TiclExponentialBackoffDelayGenerator> entry : delayGenerators.entrySet()) {
    builder.addRetryRegistrationState(
        newRetryRegistrationState(entry.getKey(), entry.getValue()));
  }
  return builder.build();
}
 
Example #6
Source File: AndroidListenerState.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Compares the contents of two {@link #delayGenerators} maps. */
private static boolean equals(Map<ObjectId, TiclExponentialBackoffDelayGenerator> x,
    Map<ObjectId, TiclExponentialBackoffDelayGenerator> y) {
  if (x.size() != y.size()) {
    return false;
  }
  for (Entry<ObjectId, TiclExponentialBackoffDelayGenerator> xEntry : x.entrySet()) {
    TiclExponentialBackoffDelayGenerator yGenerator = y.get(xEntry.getKey());
    if ((yGenerator == null) || !TypedUtil.<ExponentialBackoffState>equals(
        xEntry.getValue().marshal(), yGenerator.marshal())) {
      return false;
    }
  }
  return true;
}
 
Example #7
Source File: AndroidListenerProtos.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Creates proto for {@link AndroidListener} state. */
static AndroidListenerState newAndroidListenerState(Bytes clientId, int requestCodeSeqNum,
    Map<ObjectId, TiclExponentialBackoffDelayGenerator> delayGenerators,
    Collection<ObjectId> desiredRegistrations,
    Collection<ScheduledRegistrationRetry> registrationRetries) {
  ArrayList<RetryRegistrationState> retryRegistrationState =
      new ArrayList<RetryRegistrationState>(delayGenerators.size());
  for (Entry<ObjectId, TiclExponentialBackoffDelayGenerator> entry : delayGenerators.entrySet()) {
    retryRegistrationState.add(
        newRetryRegistrationState(entry.getKey(), entry.getValue()));
  }
  return AndroidListenerState.create(
      ProtoWrapperConverter.convertToObjectIdProtoCollection(desiredRegistrations),
      retryRegistrationState, clientId, requestCodeSeqNum, registrationRetries);
}
 
Example #8
Source File: AndroidListenerState.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Compares the contents of two {@link #delayGenerators} maps. */
private static boolean equals(Map<ObjectId, TiclExponentialBackoffDelayGenerator> x,
    Map<ObjectId, TiclExponentialBackoffDelayGenerator> y) {
  if (x.size() != y.size()) {
    return false;
  }
  for (Entry<ObjectId, TiclExponentialBackoffDelayGenerator> xEntry : x.entrySet()) {
    TiclExponentialBackoffDelayGenerator yGenerator = y.get(xEntry.getKey());
    if ((yGenerator == null) || !xEntry.getValue().marshal().toByteString().equals(
        yGenerator.marshal().toByteString())) {
      return false;
    }
  }
  return true;
}
 
Example #9
Source File: AndroidListenerProtos.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Creates proto for retry registration state. */
static RetryRegistrationState newRetryRegistrationState(ObjectId objectId,
    TiclExponentialBackoffDelayGenerator delayGenerator) {
  return RetryRegistrationState.newBuilder()
      .setObjectId(ProtoConverter.convertToObjectIdProto(objectId))
      .setExponentialBackoffState(delayGenerator.marshal())
      .build();
}
 
Example #10
Source File: AndroidListenerState.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Compares the contents of two {@link #delayGenerators} maps. */
private static boolean equals(Map<ObjectId, TiclExponentialBackoffDelayGenerator> x,
    Map<ObjectId, TiclExponentialBackoffDelayGenerator> y) {
  if (x.size() != y.size()) {
    return false;
  }
  for (Entry<ObjectId, TiclExponentialBackoffDelayGenerator> xEntry : x.entrySet()) {
    TiclExponentialBackoffDelayGenerator yGenerator = y.get(xEntry.getKey());
    if ((yGenerator == null) || !xEntry.getValue().marshal().toByteString().equals(
        yGenerator.marshal().toByteString())) {
      return false;
    }
  }
  return true;
}
 
Example #11
Source File: AndroidListenerProtos.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Creates proto for retry registration state. */
static RetryRegistrationState newRetryRegistrationState(ObjectId objectId,
    TiclExponentialBackoffDelayGenerator delayGenerator) {
  return RetryRegistrationState.newBuilder()
      .setObjectId(ProtoConverter.convertToObjectIdProto(objectId))
      .setExponentialBackoffState(delayGenerator.marshal())
      .build();
}
 
Example #12
Source File: AndroidListenerProtos.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/** Creates proto for retry registration state. */
static RetryRegistrationState newRetryRegistrationState(ObjectId objectId,
    TiclExponentialBackoffDelayGenerator delayGenerator) {
  return RetryRegistrationState.create(ProtoWrapperConverter.convertToObjectIdProto(objectId),
      delayGenerator.marshal());
}