com.google.ipc.invalidation.external.client.types.SimplePair Java Examples
The following examples show how to use
com.google.ipc.invalidation.external.client.types.SimplePair.
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: AndroidStorage.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@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)); } } }); }
Example #2
Source File: MemoryStorageImpl.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@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); } }); }
Example #3
Source File: AndroidStorage.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@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)); } } }); }
Example #4
Source File: InvalidationClientCore.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** 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); } }); }
Example #5
Source File: InvalidationClientCore.java From 365browser with Apache License 2.0 | 6 votes |
/** * 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); }
Example #6
Source File: InvalidationClientCore.java From 365browser with Apache License 2.0 | 6 votes |
/** 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); } }); }
Example #7
Source File: InvalidationClientCore.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * 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); }
Example #8
Source File: MemoryStorageImpl.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@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); } }); }
Example #9
Source File: MemoryStorageImpl.java From 365browser with Apache License 2.0 | 6 votes |
@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); } }); }
Example #10
Source File: InvalidationClientCore.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** 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); } }); }
Example #11
Source File: ProtocolHandler.java From 365browser with Apache License 2.0 | 6 votes |
/** * 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 #12
Source File: InvalidationClientCore.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * 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); }
Example #13
Source File: Statistics.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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); }
Example #14
Source File: AndroidStorage.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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)); } } }); }
Example #15
Source File: ProtocolHandler.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 #16
Source File: MemoryStorageImpl.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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); } }); }
Example #17
Source File: Statistics.java From 365browser with Apache License 2.0 | 5 votes |
/** 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())); } } }
Example #18
Source File: Statistics.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** 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())); } } }
Example #19
Source File: Statistics.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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(); }
Example #20
Source File: AndroidStorage.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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); }
Example #21
Source File: SafeStorage.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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); } }); } }); }
Example #22
Source File: SafeStorage.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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); } }); } }); }
Example #23
Source File: AndroidStorage.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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)); } } }); }
Example #24
Source File: MemoryStorageImpl.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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); } }); }
Example #25
Source File: ProtocolHandler.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 #26
Source File: SafeStorage.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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); } }); } }); }
Example #27
Source File: Statistics.java From 365browser with Apache License 2.0 | 5 votes |
/** * 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); }
Example #28
Source File: AndroidStorage.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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); }
Example #29
Source File: Statistics.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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(); }
Example #30
Source File: Statistics.java From 365browser with Apache License 2.0 | 5 votes |
@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); }