• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Status类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: scheduleStartAfterReadingStateBlob

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
/** Reads the Ticl state from persistent storage (if any) and calls {@code startInternal}. */
private void scheduleStartAfterReadingStateBlob() {
  storage.readKey(CLIENT_TOKEN_KEY, new Callback<SimplePair<Status, byte[]>>() {
    @Override
    public void accept(final SimplePair<Status, byte[]> readResult) {
      Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
      final byte[] serializedState = readResult.getFirst().isSuccess() ?
          readResult.getSecond() : null;
      // Call start now.
      if (!readResult.getFirst().isSuccess()) {
        statistics.recordError(ClientErrorType.PERSISTENT_READ_FAILURE);
        logger.warning("Could not read state blob: %s", readResult.getFirst().getMessage());
      }
      startInternal(serializedState);
    }
  });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:InvalidationClientCore.java


示例2: writeKey

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void writeKey(final String key, final byte[] value, final Callback<Status> callback) {
  // Need to schedule immediately because C++ locks aren't reentrant, and
  // C++ locking code assumes that this call will not return directly.

  // Schedule the write even if the resources are started since the
  // scheduler will prevent it from running in case the resources have been
  // stopped.
  scheduler.schedule(Scheduler.NO_DELAY,
      new NamedRunnable("MemoryStorage.writeKey") {
    @Override
    public void run() {
      ticlPersistentState.put(key, value);
      callback.accept(Status.newInstance(Status.Code.SUCCESS, ""));
    }
  });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:MemoryStorageImpl.java


示例3: readKey

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void readKey(final String key, final Callback<SimplePair<Status, byte[]>> done) {
  scheduler.schedule(Scheduler.NO_DELAY,
      new NamedRunnable("MemoryStorage.readKey") {
    @Override
    public void run() {
      byte[] value = TypedUtil.mapGet(ticlPersistentState, key);
      final SimplePair<Status, byte[]> result;
      if (value != null) {
        result = SimplePair.of(Status.newInstance(Status.Code.SUCCESS, ""), value);
      } else {
        String error = "No value present in map for " + key;
        result = SimplePair.of(Status.newInstance(Status.Code.PERMANENT_FAILURE, error), null);
      }
      done.accept(result);
    }
  });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:19,代码来源:MemoryStorageImpl.java


示例4: readKey

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void readKey(final String key, final Callback<SimplePair<Status, byte[]>> done) {
  scheduler.execute(new NamedRunnable("AndroidStorage.readKey") {
    @Override
    public void run() {
        byte [] value = properties.get(key);
        if (value != null) {
          done.accept(SimplePair.of(SUCCESS, value));
        } else {
          Status status =
              Status.newInstance(Status.Code.PERMANENT_FAILURE, "No value in map for " + key);
          done.accept(SimplePair.of(status, (byte []) null));
        }
    }
  });
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:17,代码来源:AndroidStorage.java


示例5: readAllKeys

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void readAllKeys(Callback<SimplePair<Status, String>> keyCallback) {
  // If the state file exists, supply the CLIENT_TOKEN_KEY as a present key.
  if (context.getFileStreamPath(STATE_FILENAME).exists()) {
    Status status = Status.newInstance(Status.Code.SUCCESS, "");
    keyCallback.accept(SimplePair.of(status, InvalidationClientCore.CLIENT_TOKEN_KEY));
  }
  keyCallback.accept(null);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:10,代码来源:AndroidStorage.java


示例6: writeKey

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void writeKey(String key, byte[] value, final Callback<Status> done) {
  delegate.writeKey(key, value, new Callback<Status>() {
    @Override
    public void accept(final Status status) {
      scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.writeKey") {
        @Override
        public void run() {
          done.accept(status);
        }
      });
    }
  });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java


示例7: readKey

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void readKey(String key, final Callback<SimplePair<Status, byte[]>> done) {
  delegate.readKey(key, new Callback<SimplePair<Status, byte[]>>() {
    @Override
    public void accept(final SimplePair<Status, byte[]> result) {
      scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.readKey") {
        @Override
        public void run() {
          done.accept(result);
        }
      });
    }
  });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java


示例8: readAllKeys

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void readAllKeys(final Callback<SimplePair<Status, String>> keyCallback) {
  delegate.readAllKeys(new Callback<SimplePair<Status, String>>() {
    @Override
    public void accept(final SimplePair<Status, String> keyResult) {
      scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.readAllKeys") {
        @Override
        public void run() {
          keyCallback.accept(keyResult);
        }
      });
    }
  });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java


示例9: readAllKeys

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void readAllKeys(final Callback<SimplePair<Status, String>> done) {
  scheduler.schedule(Scheduler.NO_DELAY,
      new NamedRunnable("MemoryStorage.readAllKeys") {
    @Override
    public void run() {
      Status successStatus = Status.newInstance(Status.Code.SUCCESS, "");
      for (String key : ticlPersistentState.keySet()) {
        done.accept(SimplePair.of(successStatus, key));
      }
      done.accept(null);
    }
  });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:MemoryStorageImpl.java


示例10: readAllKeys

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void readAllKeys(final Callback<SimplePair<Status, String>> keyCallback) {
  scheduler.execute(new NamedRunnable("AndroidStorage.readAllKeys") {
    @Override
    public void run() {
      for (String key : properties.keySet()) {
        keyCallback.accept(SimplePair.of(SUCCESS, key));
      }
    }
  });
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:12,代码来源:AndroidStorage.java


示例11: writeKey

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public void writeKey(final String key, final byte[] value, final Callback<Status> done) {
  scheduler.execute(new NamedRunnable("AndroidStorage.writeKey") {
    @Override
    public void run() {
      properties.put(key, value);
      store();
      done.accept(SUCCESS);
    }
  });
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:12,代码来源:AndroidStorage.java


示例12: handleServerMessage

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
/**
 * Handles a {@code message} for a {@code ticl}. If the {@code ticl} is started, delivers the
 * message. If the {@code ticl} is not started, drops the message and clears the last message send
 * time in the Ticl persistent storage so that the Ticl will send a heartbeat the next time it
 * starts.
 */
private void handleServerMessage(boolean isTiclStarted, byte[] message) {
  if (isTiclStarted) {
    // Normal case -- message for a started Ticl. Deliver the message.
    resources.getNetworkListener().onMessageReceived(message);
    return;
  }

  // Even if the client is stopped, attempt to send invalidations if the client is configured to
  // receive them.
  maybeSendBackgroundInvalidationIntent(message);

  // The Ticl isn't started. Rewrite persistent storage so that the last-send-time is a long
  // time ago. The next time the Ticl starts, it will send a message to the data center, which
  // ensures that it will be marked online and that the dropped message (or an equivalent) will
  // be delivered.
  // Android storage implementations are required to execute callbacks inline, so this code
  // all executes synchronously.
  resources.getLogger().fine("Message for unstarted Ticl; rewrite state");
  resources.getStorage().readKey(InvalidationClientCore.CLIENT_TOKEN_KEY,
      new Callback<SimplePair<Status, byte[]>>() {
    @Override
    public void accept(SimplePair<Status, byte[]> result) {
      byte[] stateBytes = result.second;
      if (stateBytes == null) {
        resources.getLogger().info("No persistent state found for client; not rewriting");
        return;
      }
      // Create new state identical to the old state except with a cleared
      // lastMessageSendTimeMs.
      PersistentTiclState state = PersistenceUtils.deserializeState(
          resources.getLogger(), stateBytes, digestFn);
      if (state == null) {
        resources.getLogger().warning("Ignoring invalid Ticl state: %s",
            Bytes.toLazyCompactString(stateBytes));
        return;
      }
      PersistentTiclState.Builder stateBuilder = state.toBuilder();
      stateBuilder.lastMessageSendTimeMs = 0L;
      state = stateBuilder.build();

      // Serialize the new state and write it to storage.
      byte[] newClientState = PersistenceUtils.serializeState(state, digestFn);
      resources.getStorage().writeKey(InvalidationClientCore.CLIENT_TOKEN_KEY, newClientState,
          new Callback<Status>() {
            @Override
            public void accept(Status status) {
              if (status.getCode() != Status.Code.SUCCESS) {
                resources.getLogger().warning(
                    "Failed saving rewritten persistent state to storage");
              }
            }
      });
    }
  });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:62,代码来源:TiclService.java


示例13: runTask

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public boolean runTask() {
  if (clientToken == null) {
    // We cannot write without a token. We must do this check before creating the
    // PersistentTiclState because newPersistentTiclState cannot handle null tokens.
    return false;
  }

  // Compute the state that we will write if we decide to go ahead with the write.
  final PersistentTiclState state =
      PersistentTiclState.create(clientToken, lastMessageSendTimeMs);
  byte[] serializedState = PersistenceUtils.serializeState(state, digestFn);

  // Decide whether or not to do the write. The decision varies depending on whether or
  // not the channel supports offline delivery. If we decide not to do the write, then
  // that means the in-memory and stored state match semantically, and the train stops.
  if (config.getChannelSupportsOfflineDelivery()) {
    // For offline delivery, we want the entire state to match, since we write the last
    // send time for every message.
    if (state.equals(lastWrittenState.get())) {
      return false;
    }
  } else {
    // If we do not support offline delivery, we avoid writing the state on each message, and
    // we avoid checking the last-sent time (we check only the client token).
    if (TypedUtil.<Bytes>equals(
        state.getClientToken(), lastWrittenState.get().getClientToken())) {
      return false;
    }
  }

  // We decided to do the write.
  storage.writeKey(CLIENT_TOKEN_KEY, serializedState, new Callback<Status>() {
    @Override
    public void accept(Status status) {
      logger.info("Write state completed: %s for %s", status, state);
      Preconditions.checkState(resources.getInternalScheduler().isRunningOnThread());
      if (status.isSuccess()) {
        // Set lastWrittenToken to be the token that was written (NOT clientToken - which
        // could have changed while the write was happening).
        lastWrittenState.set(state);
      } else {
        statistics.recordError(ClientErrorType.PERSISTENT_WRITE_FAILURE);
      }
    }
  });
  return true;  // Reschedule after timeout to make sure that write does happen.
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:49,代码来源:InvalidationClientCore.java


示例14: handleServerMessage

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
/**
 * Handles a {@code message} for a {@code ticl}. If the {@code ticl} is started, delivers the
 * message. If the {@code ticl} is not started, drops the message and clears the last message send
 * time in the Ticl persistent storage so that the Ticl will send a heartbeat the next time it
 * starts.
 */
private void handleServerMessage(boolean isTiclStarted, byte[] message) {
  if (isTiclStarted) {
    // Normal case -- message for a started Ticl. Deliver the message.
    resources.getNetworkListener().onMessageReceived(message);
    return;
  }
  // The Ticl isn't started. Rewrite persistent storage so that the last-send-time is a long
  // time ago. The next time the Ticl starts, it will send a message to the data center, which
  // ensures that it will be marked online and that the dropped message (or an equivalent) will
  // be delivered.
  // Android storage implementations are required to execute callbacks inline, so this code
  // all executes synchronously.
  resources.getLogger().fine("Message for unstarted Ticl; rewrite state");
  resources.getStorage().readKey(InvalidationClientCore.CLIENT_TOKEN_KEY,
      new Callback<SimplePair<Status, byte[]>>() {
    @Override
    public void accept(SimplePair<Status, byte[]> result) {
      byte[] stateBytes = result.second;
      if (stateBytes == null) {
        resources.getLogger().info("No persistent state found for client; not rewriting");
        return;
      }
      // Create new state identical to the old state except with a cleared
      // lastMessageSendTimeMs.
      PersistentTiclState state = PersistenceUtils.deserializeState(
          resources.getLogger(), stateBytes, digestFn);
      if (state == null) {
        resources.getLogger().warning("Ignoring invalid Ticl state: %s", stateBytes);
        return;
      }
      PersistentTiclState newState = PersistentTiclState.newBuilder(state)
          .setLastMessageSendTimeMs(0)
          .build();

      // Serialize the new state and write it to storage.
      byte[] newClientState = PersistenceUtils.serializeState(newState, digestFn);
      resources.getStorage().writeKey(InvalidationClientCore.CLIENT_TOKEN_KEY, newClientState,
          new Callback<Status>() {
            @Override
            public void accept(Status status) {
              if (status.getCode() != Status.Code.SUCCESS) {
                resources.getLogger().warning(
                    "Failed saving rewritten persistent state to storage");
              }
            }
      });
    }
  });
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:56,代码来源:TiclService.java


示例15: runTask

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
@Override
public boolean runTask() {
  if (clientToken == null) {
    // We cannot write without a token. We must do this check before creating the
    // PersistentTiclState because newPersistentTiclState cannot handle null tokens.
    return false;
  }

  // Compute the state that we will write if we decide to go ahead with the write.
  final ProtoWrapper<PersistentTiclState> state =
      ProtoWrapper.of(CommonProtos2.newPersistentTiclState(clientToken, lastMessageSendTimeMs));
  byte[] serializedState = PersistenceUtils.serializeState(state.getProto(), digestFn);

  // Decide whether or not to do the write. The decision varies depending on whether or
  // not the channel supports offline delivery. If we decide not to do the write, then
  // that means the in-memory and stored state match semantically, and the train stops.
  if (config.getChannelSupportsOfflineDelivery()) {
    // For offline delivery, we want the entire state to match, since we write the last
    // send time for every message.
    if (state.equals(lastWrittenState.get())) {
      return false;
    }
  } else {
    // If we do not support offline delivery, we avoid writing the state on each message, and
    // we avoid checking the last-sent time (we check only the client token).
    if (state.getProto().getClientToken().equals(
            lastWrittenState.get().getProto().getClientToken())) {
      return false;
    }
  }

  // We decided to do the write.
  storage.writeKey(CLIENT_TOKEN_KEY, serializedState, new Callback<Status>() {
    @Override
    public void accept(Status status) {
      logger.info("Write state completed: %s for %s", status, state.getProto());
      Preconditions.checkState(resources.getInternalScheduler().isRunningOnThread());
      if (status.isSuccess()) {
        // Set lastWrittenToken to be the token that was written (NOT clientToken - which
        // could have changed while the write was happening).
        lastWrittenState.set(state);
      } else {
        statistics.recordError(ClientErrorType.PERSISTENT_WRITE_FAILURE);
      }
    }
  });
  return true;  // Reschedule after timeout to make sure that write does happen.
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:49,代码来源:InvalidationClientCore.java


示例16: writeKey

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
/**
 * Attempts to persist {@code value} for the given {@code key}. Invokes {@code done} when
 * finished, passing a value that indicates whether it was successful.
 * <p>
 * Note: If a wrie W1 finishes unsuccessfully and then W2 is issued for the same key and W2
 * finishes successfully, W1 must NOT later overwrite W2.
 * <p>
 * REQUIRES: Neither {@code key} nor {@code value} is null.
 */
void writeKey(String key, byte[] value, Callback<Status> done);
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:SystemResources.java


示例17: readKey

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
/**
 * Reads the value corresponding to {@code key} and calls {@code done} with the result.
 * If it finds the key, passes a success status and the value. Else passes a failure status
 * and a null value.
 */
void readKey(String key, Callback<SimplePair<Status, byte[]>> done);
 
开发者ID:mogoweb,项目名称:365browser,代码行数:7,代码来源:SystemResources.java


示例18: readAllKeys

import com.google.ipc.invalidation.external.client.types.Status; //导入依赖的package包/类
/**
 * Reads all the keys from the underlying store and then calls {@code keyCallback} with
 * each key that was written earlier and not deleted. When all the keys are done, calls
 * {@code keyCallback} with {@code null}. With each key, the code can indicate a
 * failed status, in which case the iteration stops.
 */
void readAllKeys(Callback<SimplePair<Status, String>> keyCallback);
 
开发者ID:mogoweb,项目名称:365browser,代码行数:8,代码来源:SystemResources.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityFlying类代码示例发布时间:2022-05-22
下一篇:
Java UpdateCopyrightsProvider类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap