@Override @Get public Representation get() { final String opt = (String) getRequest().getAttributes().get("opt"); if ("disable_autobalancing".equalsIgnoreCase(opt)) { _helixMirrorMakerManager.disableAutoBalancing(); LOGGER.info("Disabled autobalancing!"); return new StringRepresentation("Disabled autobalancing!\n"); } else if ("enable_autobalancing".equalsIgnoreCase(opt)) { _helixMirrorMakerManager.enableAutoBalancing(); LOGGER.info("Enabled autobalancing!"); return new StringRepresentation("Enabled autobalancing!\n"); } LOGGER.info("No valid input!"); return new StringRepresentation("No valid input!\n"); }
@Override @Get public Representation get() { final String option = (String) getRequest().getAttributes().get("option"); if ("srcKafka".equals(option)) { if (_srcKafkaValidationManager == null) { LOGGER.warn("SourceKafkaClusterValidationManager is null!"); return new StringRepresentation("SrcKafkaValidationManager is not been initialized!"); } LOGGER.info("Trying to call validation on source kafka cluster!"); return new StringRepresentation(_srcKafkaValidationManager.validateSourceKafkaCluster()); } else { LOGGER.info("Trying to call validation on current cluster!"); return new StringRepresentation(_validationManager.validateExternalView()); } }
@Override @Delete public Representation delete() { final String topicName = (String) getRequest().getAttributes().get("topicName"); if (_autoTopicWhitelistingManager != null) { _autoTopicWhitelistingManager.addIntoBlacklist(topicName); } if (!_helixMirrorMakerManager.isTopicExisted(topicName)) { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new StringRepresentation( String.format("Failed to delete not existed topic: %s", topicName)); } try { _helixMirrorMakerManager.deleteTopicInMirrorMaker(topicName); return new StringRepresentation( String.format("Successfully finished delete topic: %s", topicName)); } catch (Exception e) { getResponse().setStatus(Status.SERVER_ERROR_INTERNAL); LOGGER.error("Failed to delete topic: {}, with exception: {}", topicName, e); return new StringRepresentation( String.format("Failed to delete topic: %s, with exception: %s", topicName, e)); } }
@Override @Get public Representation get() { final String topicName = (String) getRequest().getAttributes().get("topicName"); if (topicName == null) { List<String> topicLists = _helixMirrorMakerManager.getTopicLists();
public Representation post(Representation entity) { try { final String topicName = (String) getRequest().getAttributes().get("topicName"); String jsonRequest = entity.getText(); TopicPartition topicPartitionInfo = null;
@Override public void handle(Request request, Response response) { // Print the user name of the requested orders String message = "Order \"" + request.getAttributes().get("order") + "\" for user \"" + request.getAttributes().get("user") + "\""; response.setEntity(message, MediaType.TEXT_PLAIN); } };
@Override protected int beforeHandle(Request request, Response response) { request.getAttributes().put("org.restlet.startTime", getTimeMillis()); return CONTINUE; }
@Override public void handle(Request request, Response response) { // Print the user name of the requested orders String message = "Orders of user \"" + request.getAttributes().get("user") + "\""; response.setEntity(message, MediaType.TEXT_PLAIN); } };
@Override public void handle(Request request, Response response) { request.getAttributes().put("org.restlet.directory", this); super.handle(request, response); }
/** * Returns the attributes of the current Restlet {@link org.restlet.Request} * . * * @return the attributes of the current Restlet Request, but never null */ private Map<String, Object> getRequestAttributes() { return org.restlet.Request.getCurrent().getAttributes(); }
@Override protected int beforeHandle(Request request, Response response) { request.getAttributes().put("org.restlet.startTime", getTimeMillis()); return CONTINUE; }
@Override protected int beforeHandle(Request request, Response response) { request.getAttributes().put("org.restlet.startTime", getTimeMillis()); return CONTINUE; }
@Override protected void afterHandle(Request request, Response response) { long startTime = (Long) request.getAttributes().get( "org.restlet.startTime"); int duration = (int) (getTimeMillis() - startTime); analyticsHandler.addCallLogToBuffer(request, response, duration, startTime); }
protected void setResourceValidity( EntityComposite entity ) { Request request = Request.getCurrent(); ResourceValidity validity = new ResourceValidity( entity, spi, request ); request.getAttributes().put( RESOURCE_VALIDITY, validity ); }
@Override protected void doInit() throws ResourceException { // Get the "itemName" attribute value taken from the URI template // /items/{itemName}. this.itemName = (String) getRequest().getAttributes().get("itemName"); if (itemName != null) { // Get the item directly from the "persistence layer". this.item = getItems().get(itemName); } setExisting(this.item != null); }
private void addHeaderAttribute(ClientResource clientResource, String attrName, String attrValue) { ConcurrentMap<String, Object> attrs = clientResource.getRequest().getAttributes(); Series<Header> headers = (Series<Header>) attrs.get(HeaderConstants.ATTRIBUTE_HEADERS); if (headers == null) { headers = new Series<>(Header.class); Series<Header> prev = (Series<Header>) attrs.putIfAbsent(HeaderConstants.ATTRIBUTE_HEADERS, headers); if (prev != null) { headers = prev; } } headers.add(attrName, attrValue); }
@Override protected void doInit() throws ResourceException { // Get the "itemName" attribute value taken from the URI template // /items/{itemName}. this.itemName = (String) getRequest().getAttributes().get("itemName"); // Get the item directly from the "persistence layer". this.item = getItems().get(itemName); setExisting(this.item != null); }
@Override protected Representation delete(Variant variant) { String id = (String) getRequest().getAttributes().get("id"); if (!getPipelines().containsKey(id)) { return badRequest(Status.CLIENT_ERROR_NOT_FOUND, "no pipeline: " + pipelineUri(id), variant.getMediaType()); } getPipelines().remove(id); setStatus(Status.SUCCESS_OK); return new EmptyRepresentation(); } }
@Override protected Representation post(Representation entity, Variant variant) { String id = (String) getRequest().getAttributes().get("id"); if (!getPipelines().containsKey(id)) { return badRequest(Status.CLIENT_ERROR_NOT_FOUND, "no pipeline: " + pipelineUri(id), variant.getMediaType()); } PipelineConfiguration pipeconfig = getPipelines().get(id); XPipeline xpipeline = pipeconfig.pipeline; pipeconfig.reset(); xpipeline.reset(); return okResponse("Pipeline reset", variant.getMediaType()); }
@Override protected Representation post(Representation entity, Variant variant) { String id = (String) getRequest().getAttributes().get("id"); if (!getPipelines().containsKey(id)) { return badRequest(Status.CLIENT_ERROR_NOT_FOUND, "no pipeline: " + pipelineUri(id), variant.getMediaType()); } PipelineConfiguration pipeconfig = getPipelines().get(id); XPipeline xpipeline = pipeconfig.pipeline; pipeconfig.reset(); xpipeline.reset(); return okResponse("Pipeline reset", variant.getMediaType()); }