@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 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); } }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Error error = 2;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.ErrorOrBuilder getErrorOrBuilder() { if (errorBuilder_ != null) { return errorBuilder_.getMessageOrBuilder(); } else { return error_ == null ? org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error.getDefaultInstance() : error_; } } /**
"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; }
@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; }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Error error = 2;</code> */ public Builder mergeError(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error value) { if (errorBuilder_ == null) { if (error_ != null) { error_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error.newBuilder(error_).mergeFrom(value).buildPartial(); } else { error_ = value; } onChanged(); } else { errorBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Error error = 1;</code> */ public Builder mergeError(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error value) { if (errorBuilder_ == null) { if (error_ != null) { error_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error.newBuilder(error_).mergeFrom(value).buildPartial(); } else { error_ = value; } onChanged(); } else { errorBuilder_.mergeFrom(value); } return this; } /**
@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.ClientProtocol.ErrorResponse)) { return super.equals(obj); } org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol.ErrorResponse other = (org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol.ErrorResponse) obj; boolean result = true; result = result && (hasError() == other.hasError()); if (hasError()) { result = result && getError() .equals(other.getError()); } result = result && unknownFields.equals(other.unknownFields); return result; }
@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 int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (errorCode_ != org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.ErrorCode.INVALID_ERROR_CODE.getNumber()) { size += com.google.protobuf.CodedOutputStream .computeEnumSize(1, errorCode_); } if (!getMessageBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, message_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
private void addError(RegionAPI.PutAllResponse.Builder builder, BasicTypes.EncodedValue key, Exception exception) { BasicTypes.ErrorCode errorCode; if (exception instanceof NotAuthorizedException) { errorCode = AUTHORIZATION_FAILED; } else if (exception instanceof DecodingException) { errorCode = INVALID_REQUEST; } else { errorCode = SERVER_ERROR; } builder.addFailedKeys(BasicTypes.KeyedError.newBuilder().setKey(key).setError( BasicTypes.Error.newBuilder().setErrorCode(errorCode).setMessage(exception.toString()))); } }
@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; }
@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; }
@java.lang.Override public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error getDefaultInstanceForType() { return org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error.getDefaultInstance(); }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Error error = 2;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error getError() { return error_ == null ? org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Error.getDefaultInstance() : error_; } /**
@Test public void testErrorReturnedWhenNoServers() throws Exception { when(serverLocatorAdviseeMock.processRequest(any(Object.class))).thenReturn(null); LocatorAPI.GetServerRequest getServerRequest = ProtobufRequestUtilities.createGetServerRequest(); Result operationHandlerResult = getOperationHandlerResult(getServerRequest); assertTrue(operationHandlerResult instanceof Failure); Failure failure = (Failure) operationHandlerResult; ClientProtocol.ErrorResponse errorResponse = failure.getErrorMessage(); assertEquals(NO_AVAILABLE_SERVER, errorResponse.getError().getErrorCode()); }
/** * Some regions (DataPolicy.NORMAL, for example) don't support concurrent ops such as putIfAbsent. */ @Test(expected = UnsupportedOperationException.class) public void unsupportedOperation() throws Exception { when(regionMock.putIfAbsent(any(), any())).thenThrow(new UnsupportedOperationException()); Result<RegionAPI.PutIfAbsentResponse> result1 = operationHandler.process(serializationService, generateTestRequest(), TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); assertEquals(BasicTypes.ErrorCode.INVALID_REQUEST, result1.getErrorMessage().getError().getErrorCode()); }