@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + ERRORCODE_FIELD_NUMBER; hash = (53 * hash) + errorCode_; hash = (37 * hash) + MESSAGE_FIELD_NUMBER; hash = (53 * hash) + getMessage().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@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.Error)) { return super.equals(obj); } org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error other = (org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error) obj; boolean result = true; result = result && errorCode_ == other.errorCode_; result = result && getMessage() .equals(other.getMessage()); result = result && unknownFields.equals(other.unknownFields); return result; }
private Message readResponse() throws IOException { final InputStream inputStream = socket.getInputStream(); Message response = ClientProtocol.Message.parseDelimitedFrom(inputStream); if (response == null) { throw new IOException("Unable to parse a response message due to EOF"); } final ErrorResponse errorResponse = response.getErrorResponse(); if (errorResponse != null && errorResponse.hasError()) { throw new IOException(errorResponse.getError().getMessage()); } return response; }
throw new IOException( "Error finding server: error code= " + errorResponse.getError().getErrorCode() + "; error message=" + errorResponse.getError().getMessage());
@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; }
@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); } }
private void readHandshakeResponse(String username, InputStream inputStream) throws IOException { final Message authenticationResponseMessage = Message.parseDelimitedFrom(inputStream); final ErrorResponse errorResponse = authenticationResponseMessage.getErrorResponse(); if (!Objects.isNull(errorResponse) && errorResponse.hasError()) { throw new IOException("Failed authentication for " + username + ": error code=" + errorResponse.getError().getErrorCode() + "; error message=" + errorResponse.getError().getMessage()); } final ConnectionAPI.HandshakeResponse authenticationResponse = authenticationResponseMessage.getHandshakeResponse(); if (username != null && !Objects.isNull(authenticationResponse) && !authenticationResponse.getAuthenticated()) { throw new IOException("Failed authentication for " + username); } }
@Test public void testErrorReturnedForNonexistentGroup() throws Exception { when(serverLocatorAdviseeMock .processRequest(new ClientConnectionRequest(any(), NONEXISTENT_GROUP))) .thenReturn(new ClientConnectionResponse(null)); LocatorAPI.GetServerRequest getServerRequest = ProtobufRequestUtilities.createGetServerRequest(NONEXISTENT_GROUP); Result operationHandlerResult = getOperationHandlerResult(getServerRequest); assertTrue(operationHandlerResult instanceof Failure); Failure failure = (Failure) operationHandlerResult; ClientProtocol.ErrorResponse errorResponse = failure.getErrorMessage(); assertEquals(NO_AVAILABLE_SERVER, errorResponse.getError().getErrorCode()); assertTrue(errorResponse.getError().getMessage().contains(NONEXISTENT_GROUP)); }
public Builder mergeFrom(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error other) { if (other == org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error.getDefaultInstance()) return this; if (other.errorCode_ != 0) { setErrorCodeValue(other.getErrorCodeValue()); } if (!other.getMessage().isEmpty()) { message_ = other.message_; onChanged(); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** * <code>string message = 2;</code> */ public Builder clearMessage() { message_ = getDefaultInstance().getMessage(); onChanged(); return this; } /**