return qualifiedName; } catch (AtlasServiceException e) { if (ClientResponse.Status.NOT_FOUND.equals(e.getStatus())) { logger.warn("{} entity was not found for guid {}", typeName, guid); } else {
if (ClientResponse.Status.NOT_FOUND.equals(e.getStatus())) { logger.debug("nifi_flow_path was not found for qualifiedName {}", flowPathQualifiedName); } else {
if (ClientResponse.Status.NOT_FOUND.equals(e.getStatus())){ getLogger().debug("Existing flow was not found for {}@{}", new Object[]{rootProcessGroup.getId(), clusterName}); } else {
private SchemaEntry handleRegisterRequest(String path, String schema, boolean resourceNotFoundExpected) throws SchemaValidationException { SchemaEntry schemaEntry = null; try { String schemaId = webResource.path(path) .type(MediaType.TEXT_PLAIN_TYPE) .put(String.class, schema); schemaEntry = new SchemaEntry(schemaId, schema); } catch (UniformInterfaceException e) { ClientResponse cr = e.getResponse(); if (ClientResponse.Status.fromStatusCode(cr.getStatus()).equals(FORBIDDEN)) { throw new SchemaValidationException("Invalid schema: " + schema); } else { //any other status should return null handleException(e, format("Failed to register new schema for subject %s", getName()), resourceNotFoundExpected); } } catch (ClientHandlerException e) { handleException(e, format("Failed to register new schema for subject %s", getName()), resourceNotFoundExpected); } return schemaEntry; }
@Override public void removePartitionMapping(String graphId, int partitionId) { if (graphId == null) { throw new IllegalArgumentException(); } if (partitionId == Partition.INVALID_PARTITION) { throw new IllegalArgumentException(); } WebResource r = _baseResource.path(NameNodeServer.DIRECTORY).path(graphId).path(Integer.toString(partitionId)); ClientResponse response = r.delete(ClientResponse.class); Status status = response.getClientResponseStatus(); if (Status.OK.equals(status)) { return; } else if (Status.BAD_REQUEST.equals(status)) { throw new IllegalArgumentException(response.getEntity(String.class)); } throw new RuntimeException(status.toString()); } }
private SchemaEntry handleRegisterRequest(String path, String schema) throws SchemaValidationException { String schemaId; try { schemaId = webResource.path(path).type(MediaType.TEXT_PLAIN_TYPE).put(String.class, schema); return new SchemaEntry(schemaId, schema); } catch (UniformInterfaceException e) { ClientResponse cr = e.getResponse(); if (ClientResponse.Status.fromStatusCode(cr.getStatus()).equals( ClientResponse.Status.FORBIDDEN)) { throw new SchemaValidationException("Invalid schema: " + schema + ". Reason: " + cr.getEntity(String.class)); } else { //any other status should return null return null; } } catch (ClientHandlerException e) { return null; } }
private SchemaEntry handleRegisterRequest(String path, String schema) throws SchemaValidationException { String schemaId; try { schemaId = webResource.path(path).type(MediaType.TEXT_PLAIN_TYPE).put(String.class, schema); return new SchemaEntry(schemaId, schema); } catch (UniformInterfaceException e) { ClientResponse cr = e.getResponse(); if (ClientResponse.Status.fromStatusCode(cr.getStatus()).equals( ClientResponse.Status.FORBIDDEN)) { throw new SchemaValidationException("Invalid schema: " + schema); } else { //any other status should return null return null; } } catch (ClientHandlerException e) { return null; } }
@Override public ISliceSerializer getSerializer() { WebResource r = _baseResource.path(NameNodeServer.SERIALIZER); ClientResponse response = r.get(ClientResponse.class); Status status = response.getClientResponseStatus(); if (Status.OK.equals(status)) { String serializerTypeName = response.getEntity(String.class); try { return SliceSerializerProvider.loadSliceSerializer(serializerTypeName); } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } } else if (Status.NOT_FOUND.equals(status)) { return null; } throw new RuntimeException(status.toString()); }
@Override public void setSerializer(Class<? extends ISliceSerializer> sliceSerializer) { if (sliceSerializer == null) { throw new IllegalArgumentException(); } WebResource r = _baseResource.path(NameNodeServer.SERIALIZER).queryParam(NameNodeServer.SET_SERIALIZER_SERIALIZERTYPE_QP, sliceSerializer.getName()); ClientResponse response = r.put(ClientResponse.class); Status status = response.getClientResponseStatus(); if (Status.OK.equals(status)) { return; } else if (Status.BAD_REQUEST.equals(status)) { throw new IllegalArgumentException(response.getEntity(String.class)); } throw new RuntimeException(status.toString()); }
@Override public void addDataNode(URI dataNode) { if (dataNode == null) { throw new IllegalArgumentException(); } WebResource r = _baseResource.path(NameNodeServer.DATA_NODES).queryParam(NameNodeServer.ADD_DATA_NODE_DATANODE_QP, dataNode.toString()); ClientResponse response = r.put(ClientResponse.class); Status status = response.getClientResponseStatus(); if (Status.OK.equals(status)) { return; } else if (Status.BAD_REQUEST.equals(status)) { throw new IllegalArgumentException(response.getEntity(String.class)); } throw new RuntimeException(status.toString()); }
public boolean isServerReady() throws AtlasServiceException { WebResource resource = getResource(VERSION.getPath()); try { callAPIWithResource(VERSION, resource, null, JSONObject.class); return true; } catch (ClientHandlerException che) { return false; } catch (AtlasServiceException ase) { if (ase.getStatus() != null && ase.getStatus().equals(ClientResponse.Status.SERVICE_UNAVAILABLE)) { LOG.warn("Received SERVICE_UNAVAILABLE, server is not yet ready"); return false; } throw ase; } }
public boolean isServerReady() throws AtlasServiceException { WebResource resource = getResource(API_VERSION.getNormalizedPath()); try { callAPIWithResource(API_VERSION, resource, null, ObjectNode.class); return true; } catch (ClientHandlerException che) { return false; } catch (AtlasServiceException ase) { if (ase.getStatus() != null && ase.getStatus().equals(ClientResponse.Status.SERVICE_UNAVAILABLE)) { LOG.warn("Received SERVICE_UNAVAILABLE, server is not yet ready"); return false; } throw ase; } }
public boolean isServerReady() throws AtlasServiceException { WebResource resource = getResource(API_VERSION.getNormalizedPath()); try { callAPIWithResource(API_VERSION, resource, null, ObjectNode.class); return true; } catch (ClientHandlerException che) { return false; } catch (AtlasServiceException ase) { if (ase.getStatus() != null && ase.getStatus().equals(ClientResponse.Status.SERVICE_UNAVAILABLE)) { LOG.warn("Received SERVICE_UNAVAILABLE, server is not yet ready"); return false; } throw ase; } }
public boolean hasStatus(ClientResponse.Status status) { return status != null && status.equals(this.response.getClientResponseStatus()); }
@Override protected boolean matchesSafely(final UniformInterfaceException e) { return status.equals(e.getResponse().getClientResponseStatus()); }
public NexusClientNotFoundException convertIf404( final UniformInterfaceException e ) { final ClientResponse response = e.getResponse(); if ( ClientResponse.Status.NOT_FOUND.equals( response.getClientResponseStatus() ) ) { return new NexusClientNotFoundException( getMessageIfPresent( ClientResponse.Status.NOT_FOUND.getStatusCode(), e ), response.getClientResponseStatus().getReasonPhrase(), getResponseBody( response ) ); } return null; }
@Override public boolean isAvailable() { try { WebResource r = _baseResource.path(NameNodeServer.AVAILABLE); ClientResponse response = r.get(ClientResponse.class); Status status = response.getClientResponseStatus(); if (Status.OK.equals(status)) { return true; } } catch (Exception e) { } return false; }
@Override public void clearDataNodes() { WebResource r = _baseResource.path(NameNodeServer.DATA_NODES); ClientResponse response = r.delete(ClientResponse.class); Status status = response.getClientResponseStatus(); if (Status.OK.equals(status)) { return; } throw new RuntimeException(status.toString()); }
public NexusClientAccessForbiddenException convertIf403( final UniformInterfaceException e ) { final ClientResponse response = e.getResponse(); if ( ClientResponse.Status.FORBIDDEN.equals( response.getClientResponseStatus() ) ) { return new NexusClientAccessForbiddenException( getMessageIfPresent( ClientResponse.Status.FORBIDDEN.getStatusCode(), e ), response.getClientResponseStatus().getReasonPhrase(), getResponseBody( response ) ); } return null; }
public NexusClientBadRequestException convertIf400( final UniformInterfaceException e ) { final ClientResponse response = e.getResponse(); if ( ClientResponse.Status.BAD_REQUEST.equals( response.getClientResponseStatus() ) ) { return new NexusClientBadRequestException( getMessageIfPresent( ClientResponse.Status.BAD_REQUEST.getStatusCode(), e ), response.getClientResponseStatus().getReasonPhrase(), getResponseBody( response ) ); } return null; }