@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (key_ != null) { output.writeMessage(1, getKey()); } if (error_ != null) { output.writeMessage(2, getError()); } unknownFields.writeTo(output); }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (key_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, getKey()); } if (error_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, getError()); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@Override public void putAll(Map<K, V> values) throws IOException { RegionAPI.PutAllRequest.Builder putAllRequest = RegionAPI.PutAllRequest.newBuilder(); putAllRequest.setRegionName(name); for (K key : values.keySet()) { putAllRequest.addEntry(valueEncoder.encodeEntry(key, values.get(key))); } final Message request = Message.newBuilder().setPutAllRequest(putAllRequest).build(); final RegionAPI.PutAllResponse putAllResponse = protobufChannel.sendRequest(request, MessageTypeCase.PUTALLRESPONSE).getPutAllResponse(); if (0 < putAllResponse.getFailedKeysCount()) { Map<Object, String> failures = new HashMap<>(); for (BasicTypes.KeyedError keyedError : putAllResponse.getFailedKeysList()) { failures.put(valueEncoder.decodeValue(keyedError.getKey()), keyedError.getError().getMessage()); } throw new IOException("Unable to put the following keys: " + failures); } }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.KeyedError)) { return super.equals(obj); } org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.KeyedError other = (org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.KeyedError) obj; boolean result = true; result = result && (hasKey() == other.hasKey()); if (hasKey()) { result = result && getKey() .equals(other.getKey()); } result = result && (hasError() == other.hasError()); if (hasError()) { result = result && getError() .equals(other.getError()); } result = result && unknownFields.equals(other.unknownFields); return result; }
@Override public Map<K, V> getAll(Collection<K> keys) throws IOException { Map<K, V> values = new HashMap<>(); RegionAPI.GetAllRequest.Builder getAllRequest = RegionAPI.GetAllRequest.newBuilder(); getAllRequest.setRegionName(name); for (K key : keys) { getAllRequest.addKey(valueEncoder.encodeValue(key)); } Message request = Message.newBuilder().setGetAllRequest(getAllRequest).build(); Message message = protobufChannel.sendRequest(request, MessageTypeCase.GETALLRESPONSE); final RegionAPI.GetAllResponse getAllResponse = message.getGetAllResponse(); Map<Object, String> failures = new HashMap<>(); if (getAllResponse.getFailuresCount() > 0) { for (BasicTypes.KeyedError keyedError : getAllResponse.getFailuresList()) { failures.put(valueEncoder.decodeValue(keyedError.getKey()), keyedError.getError().getMessage()); } throw new IOException("Unable to process the following keys: " + failures); } for (BasicTypes.Entry entry : getAllResponse.getEntriesList()) { values.put((K) valueEncoder.decodeValue(entry.getKey()), (V) valueEncoder.decodeValue(entry.getValue())); } return values; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasKey()) { hash = (37 * hash) + KEY_FIELD_NUMBER; hash = (53 * hash) + getKey().hashCode(); } if (hasError()) { hash = (37 * hash) + ERROR_FIELD_NUMBER; hash = (53 * hash) + getError().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@Test public void multipleKeysWhereOneThrows() throws Exception { Result result = operationHandler.process(serializationService, generateTestRequest(true, true), TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); assertTrue(result instanceof Success); RegionAPI.GetAllResponse response = (RegionAPI.GetAllResponse) result.getMessage(); assertEquals(3, response.getEntriesCount()); List<BasicTypes.Entry> entriesList = response.getEntriesList(); Map<String, String> responseEntries = convertEntryListToMap(entriesList); assertEquals(TEST_VALUE1, responseEntries.get(TEST_KEY1)); assertEquals(TEST_VALUE2, responseEntries.get(TEST_KEY2)); assertEquals(TEST_VALUE3, responseEntries.get(TEST_KEY3)); assertEquals(1, response.getFailuresCount()); assertEquals(TEST_INVALID_KEY, response.getFailures(0).getKey().getStringResult()); }
@Test public void processWithInvalidEntrySucceedsAndReturnsFailedKey() throws Exception { Result result = operationHandler.process(serializationService, generateTestRequest(true, true), getNoAuthCacheExecutionContext(cacheStub)); assertTrue(result instanceof Success); verify(regionMock).put(TEST_KEY1, TEST_VALUE1); verify(regionMock).put(TEST_KEY2, TEST_VALUE2); verify(regionMock).put(TEST_KEY3, TEST_VALUE3); RegionAPI.PutAllResponse putAllResponse = (RegionAPI.PutAllResponse) result.getMessage(); assertEquals(1, putAllResponse.getFailedKeysCount()); BasicTypes.KeyedError error = putAllResponse.getFailedKeys(0); assertEquals(TEST_INVALID_KEY, serializationService.decode(error.getKey())); }
public Builder mergeFrom(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.KeyedError other) { if (other == org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.KeyedError.getDefaultInstance()) return this; if (other.hasKey()) { mergeKey(other.getKey()); } if (other.hasError()) { mergeError(other.getError()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue key = 1;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValueOrBuilder getKeyOrBuilder() { return getKey(); }