本文整理汇总了Java中com.google.ipc.invalidation.external.client.types.SimplePair类的典型用法代码示例。如果您正苦于以下问题:Java SimplePair类的具体用法?Java SimplePair怎么用?Java SimplePair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimplePair类属于com.google.ipc.invalidation.external.client.types包,在下文中一共展示了SimplePair类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sendInfoMessageToServer
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的package包/类
/**
* Sends an info message to the server. If {@code mustSendPerformanceCounters} is true,
* the performance counters are sent regardless of when they were sent earlier.
*/
private void sendInfoMessageToServer(boolean mustSendPerformanceCounters,
boolean requestServerSummary) {
logger.info("Sending info message to server; request server summary = %s",
requestServerSummary);
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
List<SimplePair<String, Integer>> performanceCounters =
new ArrayList<SimplePair<String, Integer>>();
ClientConfigP configToSend = null;
if (mustSendPerformanceCounters) {
statistics.getNonZeroStatistics(performanceCounters);
configToSend = config;
}
protocolHandler.sendInfoMessage(performanceCounters, configToSend, requestServerSummary,
batchingTask);
}
开发者ID:mogoweb,项目名称:365browser,代码行数:21,代码来源:InvalidationClientCore.java
示例2: scheduleStartAfterReadingStateBlob
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的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
示例3: readKey
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的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: sendInfoMessage
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的package包/类
/**
* 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");
}
开发者ID:mogoweb,项目名称:365browser,代码行数:26,代码来源:ProtocolHandler.java
示例5: sendInfoMessageToServer
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的package包/类
/**
* Sends an info message to the server. If {@code mustSendPerformanceCounters} is true,
* the performance counters are sent regardless of when they were sent earlier.
*/
private void sendInfoMessageToServer(boolean mustSendPerformanceCounters,
boolean requestServerSummary) {
logger.info("Sending info message to server; request server summary = %s",
requestServerSummary);
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
List<SimplePair<String, Integer>> performanceCounters =
new ArrayList<SimplePair<String, Integer>>();
List<SimplePair<String, Integer>> configParams =
new ArrayList<SimplePair<String, Integer>>();
ClientConfigP configToSend = null;
if (mustSendPerformanceCounters) {
statistics.getNonZeroStatistics(performanceCounters);
configToSend = config;
}
protocolHandler.sendInfoMessage(performanceCounters, configToSend, requestServerSummary,
batchingTask);
}
开发者ID:morristech,项目名称:android-chromium,代码行数:23,代码来源:InvalidationClientCore.java
示例6: readKey
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的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
示例7: getNonZeroStatistics
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的package包/类
/**
* Modifies {@code performanceCounters} to contain all the statistics that are non-zero. Each pair
* has the name of the statistic event and the number of times that event has occurred since the
* client started.
*/
public void getNonZeroStatistics(List<SimplePair<String, Integer>> performanceCounters) {
// Add the non-zero values from the different maps to performanceCounters.
fillWithNonZeroStatistics(sentMessageTypes, performanceCounters, SENT_MESSAGE_TYPE_NAME);
fillWithNonZeroStatistics(receivedMessageTypes, performanceCounters,
RECEIVED_MESSAGE_TYPE_NAME);
fillWithNonZeroStatistics(incomingOperationTypes, performanceCounters,
INCOMING_OPERATION_TYPE_NAME);
fillWithNonZeroStatistics(listenerEventTypes, performanceCounters, LISTENER_EVENT_TYPE_NAME);
fillWithNonZeroStatistics(clientErrorTypes, performanceCounters, CLIENT_ERROR_TYPE_NAME);
}
开发者ID:mogoweb,项目名称:365browser,代码行数:16,代码来源:Statistics.java
示例8: fillWithNonZeroStatistics
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的package包/类
/** Modifies {@code result} to contain those statistics from {@code map} whose value is > 0. */
private static <Key extends Enum<Key>> void fillWithNonZeroStatistics(Map<Key, Integer> map,
List<SimplePair<String, Integer>> destination, String typeName) {
String prefix = typeName + ".";
for (Map.Entry<Key, Integer> entry : map.entrySet()) {
if (entry.getValue() > 0) {
destination.add(SimplePair.of(prefix + entry.getKey().name(), entry.getValue()));
}
}
}
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:Statistics.java
示例9: marshal
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的package包/类
@Override
public StatisticsState marshal() {
// Get all the non-zero counters, convert them to proto PropertyRecord messages, and return
// a StatisticsState containing the records.
List<SimplePair<String, Integer>> counters = new ArrayList<SimplePair<String, Integer>>();
getNonZeroStatistics(counters);
List<PropertyRecord> propertyRecords = new ArrayList<PropertyRecord>(counters.size());
for (SimplePair<String, Integer> counter : counters) {
propertyRecords.add(PropertyRecord.create(counter.getFirst(), counter.getSecond()));
}
return StatisticsState.create(propertyRecords);
}
开发者ID:mogoweb,项目名称:365browser,代码行数:13,代码来源:Statistics.java
示例10: readAllKeys
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的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
示例11: readKey
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的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
示例12: readAllKeys
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的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
示例13: readAllKeys
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的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
示例14: marshal
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的package包/类
@Override
public StatisticsState marshal() {
// Get all the non-zero counters, convert them to proto PropertyRecord messages, and return
// a StatisticsState containing the records.
StatisticsState.Builder builder = StatisticsState.newBuilder();
List<SimplePair<String, Integer>> counters = new ArrayList<SimplePair<String, Integer>>();
getNonZeroStatistics(counters);
for (SimplePair<String, Integer> counter : counters) {
builder.addCounter(CommonProtos2.newPropertyRecord(counter.getFirst(), counter.getSecond()));
}
return builder.build();
}
开发者ID:morristech,项目名称:android-chromium,代码行数:13,代码来源:Statistics.java
示例15: readAllKeys
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的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
示例16: sendInfoMessage
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的package包/类
/**
* 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");
}
开发者ID:morristech,项目名称:android-chromium,代码行数:35,代码来源:ProtocolHandler.java
示例17: toCompactString
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的package包/类
@Override
public void toCompactString(TextBuilder builder) {
List<SimplePair<String, Integer>> nonZeroValues = new ArrayList<SimplePair<String, Integer>>();
getNonZeroStatistics(nonZeroValues);
builder.appendFormat("Client Statistics: %s\n", nonZeroValues);
}
开发者ID:mogoweb,项目名称:365browser,代码行数:7,代码来源:Statistics.java
示例18: handleServerMessage
import com.google.ipc.invalidation.external.client.types.SimplePair; //导入依赖的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
注:本文中的com.google.ipc.invalidation.external.client.types.SimplePair类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论