Examples of StringRepresentation


Examples of org.restlet.resource.StringRepresentation

   
    String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);
   
    String message = ClusterRepresentationUtil.getInstancePropertyNameListAsString(zkClient, clusterName, instanceName, PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON);

    StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON);

    return representation;
  }
View Full Code Here

Examples of org.restlet.resource.StringRepresentation

  }

  @Override
  public Representation represent(Variant variant)
  {
    StringRepresentation presentation = null;
    String zkPath = getZKPath();

    try
    {
      ZkClient zkClient =
          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
      ZNRecord result = readZkChild(zkPath, zkClient);

      presentation =
          new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(result),
                                   MediaType.APPLICATION_JSON);
    }
    catch (Exception e)
    {
      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);

      LOG.error("Error in read zkPath: " + zkPath, e);
    }

    return presentation;
View Full Code Here

Examples of org.restlet.resource.StringRepresentation

  }

  @Override
  public Representation represent(Variant variant)
  {
    StringRepresentation presentation = null;
    try
    {
      String clusterName = (String) getRequest().getAttributes().get("clusterName");
      String modelName = (String) getRequest().getAttributes().get("modelName");
      presentation = getStateModelRepresentation(clusterName, modelName);
    }

    catch (Exception e)
    {
      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);

      LOG.error("", e);
    }
    return presentation;
  }
View Full Code Here

Examples of org.restlet.resource.StringRepresentation

        ClusterRepresentationUtil.getClusterPropertyAsString(zkClient,
                                                             clusterName,
                                                             keyBuilder.stateModelDef(modelName),
                                                             MediaType.APPLICATION_JSON);

    StringRepresentation representation =
        new StringRepresentation(message, MediaType.APPLICATION_JSON);

    return representation;
  }
View Full Code Here

Examples of org.restlet.resource.StringRepresentation

  }

  @Override
  public Representation represent(Variant variant)
  {
    StringRepresentation presentation = null;
    try
    {
      String clusterName = (String) getRequest().getAttributes().get("clusterName");
      presentation = getClusterRepresentation(clusterName);
    }

    catch (Exception e)
    {
      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);

      e.printStackTrace();
    }
    return presentation;
  }
View Full Code Here

Examples of org.restlet.resource.StringRepresentation

    }
    else
    {
      clusterSummayRecord.setSimpleField("LEADER", "");
    }
    StringRepresentation representation =
        new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(clusterSummayRecord),
                                 MediaType.APPLICATION_JSON);

    return representation;
  }
View Full Code Here

Examples of org.restlet.resource.StringRepresentation

  }

  @Override
  public Representation represent(Variant variant)
  {
    StringRepresentation presentation = null;
    try
    {
      String zkServer = (String) getContext().getAttributes().get(
          RestAdminApplication.ZKSERVERADDRESS);
      String clusterName = (String) getRequest().getAttributes().get(
          "clusterName");
      String messageType = (String) getRequest().getAttributes().get(
          "MessageType");
      String messageId = (String) getRequest().getAttributes().get("MessageId");
      // TODO: need pass sessionId to this represent()
      String sessionId = (String) getRequest().getAttributes().get("SessionId");

      presentation = getControllerStatusUpdateRepresentation(zkServer,
          clusterName, sessionId, messageType, messageId);
    } catch (Exception e)
    {
      String error = ClusterRepresentationUtil
          .getErrorAsJsonStringFromException(e);
      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
      LOG.error("", e);
    }
    return presentation;
  }
View Full Code Here

Examples of org.restlet.resource.StringRepresentation

    String message = ClusterRepresentationUtil.getPropertyAsString(
        zkClient,
        clusterName,
        keyBuilder.controllerTaskStatus(messageType, messageId),
        MediaType.APPLICATION_JSON);
    StringRepresentation representation = new StringRepresentation(message,
        MediaType.APPLICATION_JSON);
    return representation;
  }
View Full Code Here

Examples of org.restlet.resource.StringRepresentation

  }

  @Override
  public Representation represent(Variant variant)
  {
    StringRepresentation presentation = null;
    try
    {
      String clusterName = (String) getRequest().getAttributes().get("clusterName");
      presentation = getInstancesRepresentation(clusterName);
    }

    catch (Exception e)
    {
      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);

      LOG.error("", e);
    }
    return presentation;
  }
View Full Code Here

Examples of org.restlet.resource.StringRepresentation

      instanceConfigsMap.get(instanceName)
                        .getRecord()
                        .setSimpleField("Alive", isAlive + "");
    }

    StringRepresentation representation =
        new StringRepresentation(ClusterRepresentationUtil.ObjectToJson(instanceConfigsMap.values()),
                                 MediaType.APPLICATION_JSON);

    return representation;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.