You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ki...@apache.org on 2012/10/25 00:26:40 UTC

[4/47] Refactoring from com.linkedin.helix to org.apache.helix

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ControllerResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ControllerResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ControllerResource.java
deleted file mode 100644
index 60e4763..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ControllerResource.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.data.MediaType;
-import org.restlet.data.Status;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.HelixException;
-import com.linkedin.helix.HelixProperty;
-import com.linkedin.helix.PropertyKey;
-import com.linkedin.helix.PropertyKey.Builder;
-import com.linkedin.helix.PropertyType;
-import com.linkedin.helix.ZNRecord;
-import com.linkedin.helix.manager.zk.ZKHelixDataAccessor;
-import com.linkedin.helix.manager.zk.ZkBaseDataAccessor;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.model.LiveInstance;
-import com.linkedin.helix.model.PauseSignal;
-import com.linkedin.helix.tools.ClusterSetup;
-import com.linkedin.helix.util.StatusUpdateUtil.Level;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class ControllerResource extends Resource
-{
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  StringRepresentation getControllerRepresentation(String clusterName) throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
-    Builder keyBuilder = new PropertyKey.Builder(clusterName);
-    ZkClient zkClient =
-        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-
-    ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
-
-
-    ZNRecord record = null;
-    LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
-    if (leader != null)
-    {
-      record = leader.getRecord();
-    }
-    else
-    {
-      record = new ZNRecord("");
-      DateFormat formatter = new SimpleDateFormat("yyyyMMdd-HHmmss.SSSSSS");
-      String time = formatter.format(new Date());
-      Map<String, String> contentMap = new TreeMap<String, String>();
-      contentMap.put("AdditionalInfo", "No leader exists");
-      record.setMapField(Level.HELIX_INFO + "-" + time, contentMap);
-    }
-    
-    boolean paused = (accessor.getProperty(keyBuilder.pause()) == null? false : true);
-    record.setSimpleField(PropertyType.PAUSE.toString(), "" + paused);
-
-    String retVal = ClusterRepresentationUtil.ZNRecordToJson(record);
-    StringRepresentation representation =
-        new StringRepresentation(retVal, MediaType.APPLICATION_JSON);
-
-    return representation;
-  }
-
-  @Override
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      presentation = getControllerRepresentation(clusterName);
-    }
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-      e.printStackTrace();
-    }
-    return presentation;
-  }
-
-  @Override
-  public void acceptRepresentation(Representation entity)
-  {
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      ZkClient zkClient =
-          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-      ClusterSetup setupTool = new ClusterSetup(zkClient);
-
-      JsonParameters jsonParameters = new JsonParameters(entity);
-      String command = jsonParameters.getCommand();
-
-      if (command == null)
-      {
-        throw new HelixException("Could NOT find 'command' in parameterMap: " + jsonParameters._parameterMap);
-      }
-      else if (command.equalsIgnoreCase(ClusterSetup.enableCluster))
-      {
-        boolean enabled =
-            Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));
-
-        setupTool.getClusterManagementTool().enableCluster(clusterName, enabled);
-      }
-      else
-      {
-        throw new HelixException("Unsupported command: " + command
-                                 + ". Should be one of [" + ClusterSetup.enableCluster + "]");
-      }
-      
-      getResponse().setEntity(getControllerRepresentation(clusterName));
-      getResponse().setStatus(Status.SUCCESS_OK);
-
-    }
-    catch (Exception e)
-    {
-      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
-                              MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ControllerStatusUpdateResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ControllerStatusUpdateResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ControllerStatusUpdateResource.java
deleted file mode 100644
index a29ae35..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ControllerStatusUpdateResource.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.PropertyKey;
-import com.linkedin.helix.PropertyKey.Builder;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class ControllerStatusUpdateResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(ControllerStatusUpdateResource.class);
-
-  public ControllerStatusUpdateResource(Context context, Request request,
-      Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  @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;
-  }
-
-  StringRepresentation getControllerStatusUpdateRepresentation(
-      String zkServerAddress, String clusterName, String sessionId,
-      String messageType, String messageId) throws JsonGenerationException,
-      JsonMappingException, IOException
-  {
-    Builder keyBuilder = new PropertyKey.Builder(clusterName);
-    ZkClient zkClient = (ZkClient)getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-    String message = ClusterRepresentationUtil.getPropertyAsString(
-        zkClient,
-        clusterName,
-        keyBuilder.controllerTaskStatus(messageType, messageId),
-        MediaType.APPLICATION_JSON);
-    StringRepresentation representation = new StringRepresentation(message,
-        MediaType.APPLICATION_JSON);
-    return representation;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/CurrentStateResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/CurrentStateResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/CurrentStateResource.java
deleted file mode 100644
index 54c36f7..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/CurrentStateResource.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.PropertyKey;
-import com.linkedin.helix.PropertyKey.Builder;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class CurrentStateResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(CurrentStateResource.class);
-
-  public CurrentStateResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  @Override
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String instanceName = (String) getRequest().getAttributes().get("instanceName");
-      String resourceGroup = (String) getRequest().getAttributes().get("resourceName");
-
-      presentation =
-          getInstanceCurrentStateRepresentation(
-                                                clusterName,
-                                                instanceName,
-                                                resourceGroup);
-    }
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }
-    return presentation;
-  }
-
-  StringRepresentation getInstanceCurrentStateRepresentation(
-                                                             String clusterName,
-                                                             String instanceName,
-                                                             String resourceGroup) throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
-    ZkClient zkClient = (ZkClient)getRequest().getAttributes().get(RestAdminApplication.ZKCLIENT);
-    String instanceSessionId =
-        ClusterRepresentationUtil.getInstanceSessionId(zkClient,
-                                                       clusterName,
-                                                       instanceName);
-    Builder keyBuilder = new PropertyKey.Builder(clusterName);
-
-    String message =
-        ClusterRepresentationUtil.getInstancePropertyAsString(zkClient,
-                                                              clusterName,
-                                                              keyBuilder.currentState(instanceName,
-                                                                                      instanceSessionId,
-                                                                                      resourceGroup),
-                                                              MediaType.APPLICATION_JSON);
-    StringRepresentation representation =
-        new StringRepresentation(message, MediaType.APPLICATION_JSON);
-    return representation;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/CurrentStatesResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/CurrentStatesResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/CurrentStatesResource.java
deleted file mode 100644
index 35358bb..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/CurrentStatesResource.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.PropertyType;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class CurrentStatesResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(CurrentStatesResource.class);
-
-  public CurrentStatesResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  public boolean allowPost()
-  {
-    return false;
-  }
-
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String instanceName = (String) getRequest().getAttributes().get("instanceName");
-      presentation = getInstanceCurrentStatesRepresentation(clusterName, instanceName);
-    }
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }
-    return presentation;
-  }
-
-  StringRepresentation getInstanceCurrentStatesRepresentation(String clusterName, String instanceName) throws JsonGenerationException, JsonMappingException, IOException
-  {
-    ZkClient zkClient = (ZkClient)getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);;
-    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;
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ErrorResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ErrorResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ErrorResource.java
deleted file mode 100644
index d9e916c..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ErrorResource.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.PropertyKey;
-import com.linkedin.helix.PropertyKey.Builder;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class ErrorResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(ErrorResource.class);
-
-  public ErrorResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  @Override
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String instanceName = (String) getRequest().getAttributes().get("instanceName");
-      String resourceGroup = (String) getRequest().getAttributes().get("resourceName");
-
-      presentation =
-          getInstanceErrorsRepresentation(clusterName,
-                                          instanceName,
-                                          resourceGroup);
-    }
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }
-    return presentation;
-  }
-
-  StringRepresentation getInstanceErrorsRepresentation(String clusterName,
-                                                       String instanceName,
-                                                       String resourceGroup) throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
-    ZkClient zkClient = (ZkClient)getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-    String instanceSessionId =
-        ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName,
-                                                       instanceName);
-    Builder keyBuilder = new PropertyKey.Builder(clusterName);
-    String message =
-        ClusterRepresentationUtil.getInstancePropertiesAsString(zkClient, clusterName,
-                                                                keyBuilder.stateTransitionErrors(instanceName,
-                                                                                                 instanceSessionId,
-                                                                                                 resourceGroup),
-                                                                // instanceSessionId
-                                                                // + "__"
-                                                                // + resourceGroup,
-                                                                MediaType.APPLICATION_JSON);
-    StringRepresentation representation =
-        new StringRepresentation(message, MediaType.APPLICATION_JSON);
-    return representation;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ErrorsResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ErrorsResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ErrorsResource.java
deleted file mode 100644
index 8ea29c7..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ErrorsResource.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.PropertyType;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class ErrorsResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(ErrorsResource.class);
-
-  public ErrorsResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  public boolean allowPost()
-  {
-    return false;
-  }
-
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String instanceName = (String) getRequest().getAttributes().get("instanceName");
-      presentation = getInstanceErrorsRepresentation( clusterName, instanceName);
-    }
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }
-    return presentation;
-  }
-
-  StringRepresentation getInstanceErrorsRepresentation(String clusterName, String instanceName) throws JsonGenerationException, JsonMappingException, IOException
-  {
-    ZkClient zkClient = (ZkClient)getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);;
-    
-    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;
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ExternalViewResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ExternalViewResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ExternalViewResource.java
deleted file mode 100644
index 3c34d1e..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ExternalViewResource.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.PropertyKey;
-import com.linkedin.helix.PropertyKey.Builder;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class ExternalViewResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(ExternalViewResource.class);
-
-  public ExternalViewResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  @Override
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String resourceName = (String) getRequest().getAttributes().get("resourceName");
-      presentation = getExternalViewRepresentation( clusterName, resourceName);
-    }
-
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }
-    return presentation;
-  }
-
-  StringRepresentation getExternalViewRepresentation(String clusterName,
-                                                     String resourceName) throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
-    Builder keyBuilder = new PropertyKey.Builder(clusterName);
-    ZkClient zkClient = (ZkClient)getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);;
-    
-    String message =
-        ClusterRepresentationUtil.getClusterPropertyAsString(zkClient,
-                                                             clusterName,
-                                                             keyBuilder.externalView(resourceName),
-                                                             MediaType.APPLICATION_JSON);
-    StringRepresentation representation =
-        new StringRepresentation(message, MediaType.APPLICATION_JSON);
-
-    return representation;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/IdealStateResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/IdealStateResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/IdealStateResource.java
deleted file mode 100644
index 1119c29..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/IdealStateResource.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.data.Status;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.HelixDataAccessor;
-import com.linkedin.helix.HelixException;
-import com.linkedin.helix.PropertyKey;
-import com.linkedin.helix.PropertyKey.Builder;
-import com.linkedin.helix.ZNRecord;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.model.IdealState;
-import com.linkedin.helix.tools.ClusterSetup;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class IdealStateResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(IdealStateResource.class);
-
-  public IdealStateResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  @Override
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String resourceName = (String) getRequest().getAttributes().get("resourceName");
-      presentation = getIdealStateRepresentation(clusterName, resourceName);
-    }
-
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }
-    return presentation;
-  }
-
-  StringRepresentation getIdealStateRepresentation(String clusterName, String resourceName) throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
-    Builder keyBuilder = new PropertyKey.Builder(clusterName);
-    ZkClient zkClient =
-        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-
-    String message =
-        ClusterRepresentationUtil.getClusterPropertyAsString(zkClient,
-                                                             clusterName,
-                                                             keyBuilder.idealStates(resourceName),
-                                                             MediaType.APPLICATION_JSON);
-
-    StringRepresentation representation =
-        new StringRepresentation(message, MediaType.APPLICATION_JSON);
-
-    return representation;
-  }
-
-  @Override
-  public void acceptRepresentation(Representation entity)
-  {
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String resourceName = (String) getRequest().getAttributes().get("resourceName");
-      ZkClient zkClient =
-          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-      ClusterSetup setupTool = new ClusterSetup(zkClient);
-
-      JsonParameters jsonParameters = new JsonParameters(entity);
-      String command = jsonParameters.getCommand();
-
-      if (command.equalsIgnoreCase(ClusterSetup.addIdealState))
-      {
-        ZNRecord newIdealState = jsonParameters.getExtraParameter(JsonParameters.NEW_IDEAL_STATE);
-        HelixDataAccessor accessor =
-            ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
-
-        accessor.setProperty(accessor.keyBuilder().idealStates(resourceName),
-                             new IdealState(newIdealState));
-
-      }
-      else if (command.equalsIgnoreCase(ClusterSetup.rebalance))
-      {
-        int replicas = 
-            Integer.parseInt(jsonParameters.getParameter(JsonParameters.REPLICAS));
-        if (jsonParameters.getParameter(JsonParameters.RESOURCE_KEY_PREFIX) != null)
-        {
-          setupTool.rebalanceStorageCluster(clusterName,
-                                            resourceName,
-                                            replicas,
-                                            jsonParameters.getParameter(JsonParameters.RESOURCE_KEY_PREFIX));
-        }
-        else
-        {
-          setupTool.rebalanceStorageCluster(clusterName, resourceName, replicas);
-        }
-      }
-      else if (command.equalsIgnoreCase(ClusterSetup.expandResource))
-      {
-        setupTool.expandResource(clusterName, resourceName);
-      }
-      else if (command.equalsIgnoreCase(ClusterSetup.addResourceProperty))
-      {
-        Map<String, String> parameterMap = jsonParameters.cloneParameterMap();
-        parameterMap.remove(JsonParameters.MANAGEMENT_COMMAND);
-        for (String key : parameterMap.keySet())
-        {
-          setupTool.addResourceProperty(clusterName,
-                                        resourceName,
-                                        key,
-                                        parameterMap.get(key));
-        }
-      }
-      else
-      {
-        throw new HelixException("Unsupported command: " + command
-            + ". Should be one of [" + ClusterSetup.addIdealState + ", "
-            + ClusterSetup.rebalance + ", " + ClusterSetup.expandResource + ", "
-            + ClusterSetup.addResourceProperty + "]");
-      }
-
-      getResponse().setEntity(getIdealStateRepresentation(clusterName, resourceName));
-      getResponse().setStatus(Status.SUCCESS_OK);
-    }
-    catch (Exception e)
-    {
-      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
-                              MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-      LOG.error("Error in posting " + entity, e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/InstanceResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/InstanceResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/InstanceResource.java
deleted file mode 100644
index e854182..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/InstanceResource.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.data.Status;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.HelixException;
-import com.linkedin.helix.PropertyKey;
-import com.linkedin.helix.PropertyKey.Builder;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.tools.ClusterSetup;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class InstanceResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(InstanceResource.class);
-
-  public InstanceResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return true;
-  }
-
-  @Override
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      presentation = getInstanceRepresentation();
-    }
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }
-    return presentation;
-  }
-
-  StringRepresentation getInstanceRepresentation() throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
-    String clusterName = (String) getRequest().getAttributes().get("clusterName");
-    String instanceName = (String) getRequest().getAttributes().get("instanceName");
-    Builder keyBuilder = new PropertyKey.Builder(clusterName);
-    ZkClient zkClient =
-        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-
-    String message =
-        ClusterRepresentationUtil.getClusterPropertyAsString(zkClient,
-                                                             clusterName,
-                                                             MediaType.APPLICATION_JSON,
-                                                             keyBuilder.instanceConfig(instanceName));
-
-    StringRepresentation representation =
-        new StringRepresentation(message, MediaType.APPLICATION_JSON);
-
-    return representation;
-  }
-
-  @Override
-  public void acceptRepresentation(Representation entity)
-  {
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String instanceName = (String) getRequest().getAttributes().get("instanceName");
-
-      JsonParameters jsonParameters = new JsonParameters(entity);
-      String command = jsonParameters.getCommand();
-      if (command.equalsIgnoreCase(ClusterSetup.enableInstance))
-      {
-        jsonParameters.verifyCommand(ClusterSetup.enableInstance);
-
-        boolean enabled =
-            Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));
-
-        ZkClient zkClient =
-            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-        ClusterSetup setupTool = new ClusterSetup(zkClient);
-        setupTool.getClusterManagementTool().enableInstance(clusterName,
-                                                            instanceName,
-                                                            enabled);
-      }
-      else if (command.equalsIgnoreCase(ClusterSetup.enablePartition))
-      {
-        jsonParameters.verifyCommand(ClusterSetup.enablePartition);
- 
-        boolean enabled =
-             Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));
-
-        String[] partitions = 
-            jsonParameters.getParameter(JsonParameters.PARTITION).split(";");
-        String resource = 
-            jsonParameters.getParameter(JsonParameters.RESOURCE);
-
-        ZkClient zkClient =
-            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-        ClusterSetup setupTool = new ClusterSetup(zkClient);
-        setupTool.getClusterManagementTool().enablePartition(enabled,
-                                                             clusterName,
-                                                             instanceName,
-                                                             resource,
-                                                             Arrays.asList(partitions));
-      }
-      else if (command.equalsIgnoreCase(ClusterSetup.resetPartition))
-      {
-        jsonParameters.verifyCommand(ClusterSetup.resetPartition);
-
-        String resource = 
-            jsonParameters.getParameter(JsonParameters.RESOURCE);
-
-        ZkClient zkClient =
-            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-        ClusterSetup setupTool = new ClusterSetup(zkClient);
-        String[] partitionNames = 
-            jsonParameters.getParameter(JsonParameters.PARTITION).split("\\s+");
-        setupTool.getClusterManagementTool()
-                 .resetPartition(clusterName,
-                                 instanceName,
-                                 resource,
-                                 Arrays.asList(partitionNames));
-      }
-      else if (command.equalsIgnoreCase(ClusterSetup.resetInstance))
-      {
-        jsonParameters.verifyCommand(ClusterSetup.resetInstance);
-
-        ZkClient zkClient =
-            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-        ClusterSetup setupTool = new ClusterSetup(zkClient);
-        setupTool.getClusterManagementTool().resetInstance(clusterName,
-                                                           Arrays.asList(instanceName));
-      }
-      else
-      {
-        throw new HelixException("Unsupported command: " + command
-            + ". Should be one of [" + ClusterSetup.enableInstance + ", "
-            + ClusterSetup.enablePartition + ", " + ClusterSetup.resetInstance + "]");
-      }
-
-      getResponse().setEntity(getInstanceRepresentation());
-      getResponse().setStatus(Status.SUCCESS_OK);
-    }
-    catch (Exception e)
-    {
-      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
-                              MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-      LOG.error("", e);
-    }
-  }
-
-  @Override
-  public void removeRepresentations()
-  {
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String instanceName = (String) getRequest().getAttributes().get("instanceName");
-      ZkClient zkClient =
-          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-
-      ClusterSetup setupTool = new ClusterSetup(zkClient);
-      setupTool.dropInstanceFromCluster(clusterName, instanceName);
-      getResponse().setStatus(Status.SUCCESS_OK);
-    }
-    catch (Exception e)
-    {
-      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
-                              MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-      LOG.error("Error in remove", e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/InstancesResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/InstancesResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/InstancesResource.java
deleted file mode 100644
index 038b66b..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/InstancesResource.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.data.Status;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.HelixDataAccessor;
-import com.linkedin.helix.HelixException;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.model.InstanceConfig;
-import com.linkedin.helix.model.LiveInstance;
-import com.linkedin.helix.tools.ClusterSetup;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class InstancesResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(InstancesResource.class);
-
-  public InstancesResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  @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;
-  }
-
-  StringRepresentation getInstancesRepresentation(String clusterName) throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
-    ZkClient zkClient =
-        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-
-    HelixDataAccessor accessor =
-        ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
-    Map<String, LiveInstance> liveInstancesMap =
-        accessor.getChildValuesMap(accessor.keyBuilder().liveInstances());
-    Map<String, InstanceConfig> instanceConfigsMap =
-        accessor.getChildValuesMap(accessor.keyBuilder().instanceConfigs());
-
-    for (String instanceName : instanceConfigsMap.keySet())
-    {
-      boolean isAlive = liveInstancesMap.containsKey(instanceName);
-      instanceConfigsMap.get(instanceName)
-                        .getRecord()
-                        .setSimpleField("Alive", isAlive + "");
-    }
-
-    StringRepresentation representation =
-        new StringRepresentation(ClusterRepresentationUtil.ObjectToJson(instanceConfigsMap.values()),
-                                 MediaType.APPLICATION_JSON);
-
-    return representation;
-  }
-
-  @Override
-  public void acceptRepresentation(Representation entity)
-  {
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      JsonParameters jsonParameters = new JsonParameters(entity);
-      String command = jsonParameters.getCommand();
-
-      ZkClient zkClient =
-          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-      ClusterSetup setupTool = new ClusterSetup(zkClient);
-
-      if (command.equalsIgnoreCase(ClusterSetup.addInstance)
-          || JsonParameters.CLUSTERSETUP_COMMAND_ALIASES.get(ClusterSetup.addInstance)
-                                                        .contains(command))
-      {
-        if (jsonParameters.getParameter(JsonParameters.INSTANCE_NAME) != null)
-        {
-          setupTool.addInstanceToCluster(clusterName,
-                                         jsonParameters.getParameter(JsonParameters.INSTANCE_NAME));
-        }
-        else if (jsonParameters.getParameter(JsonParameters.INSTANCE_NAMES) != null)
-        {
-          setupTool.addInstancesToCluster(clusterName,
-                                          jsonParameters.getParameter(JsonParameters.INSTANCE_NAMES)
-                                                        .split(";"));
-        }
-        else
-        {
-          throw new HelixException("Missing Json paramaters: '"
-              + JsonParameters.INSTANCE_NAME + "' or '" + JsonParameters.INSTANCE_NAMES
-              + "' ");
-        }
-      }
-      else if (command.equalsIgnoreCase(ClusterSetup.swapInstance))
-      {
-        if (jsonParameters.getParameter(JsonParameters.NEW_INSTANCE) == null
-            || jsonParameters.getParameter(JsonParameters.OLD_INSTANCE) == null)
-        {
-          throw new HelixException("Missing Json paramaters: '"
-              + JsonParameters.NEW_INSTANCE + "' or '" + JsonParameters.OLD_INSTANCE
-              + "' ");
-        }
-        setupTool.swapInstance(clusterName,
-                               jsonParameters.getParameter(JsonParameters.OLD_INSTANCE),
-                               jsonParameters.getParameter(JsonParameters.NEW_INSTANCE));
-      }
-      else
-      {
-        throw new HelixException("Unsupported command: " + command
-            + ". Should be one of [" + ClusterSetup.addInstance + ", "
-            + ClusterSetup.swapInstance + "]");
-      }
-
-      getResponse().setEntity(getInstancesRepresentation(clusterName));
-      getResponse().setStatus(Status.SUCCESS_OK);
-    }
-    catch (Exception e)
-    {
-      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
-                              MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-      LOG.error("", e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/JsonParameters.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/JsonParameters.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/JsonParameters.java
deleted file mode 100644
index dc79a6a..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/JsonParameters.java
+++ /dev/null
@@ -1,248 +0,0 @@
-package com.linkedin.helix.webapp.resources;
-
-import java.io.StringReader;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.codehaus.jackson.map.ObjectMapper;
-import org.restlet.data.Form;
-import org.restlet.resource.Representation;
-
-import com.linkedin.helix.HelixException;
-import com.linkedin.helix.ZNRecord;
-import com.linkedin.helix.tools.ClusterSetup;
-
-public class JsonParameters
-{
-  // json parameter key
-  public static final String             JSON_PARAMETERS     = "jsonParameters";
-
-  // json parameter map keys
-  public static final String             PARTITION           = "partition";
-  public static final String             RESOURCE            = "resource";
-  public static final String             MANAGEMENT_COMMAND  = "command";
-  public static final String             ENABLED             = "enabled";
-  public static final String             GRAND_CLUSTER       = "grandCluster";
-  public static final String             REPLICAS            = "replicas";
-  public static final String             RESOURCE_KEY_PREFIX = "key";
-  public static final String             INSTANCE_NAME       = "instanceName";
-  public static final String             INSTANCE_NAMES      = "instanceNames";
-  public static final String             OLD_INSTANCE        = "oldInstance";
-  public static final String             NEW_INSTANCE        = "newInstance";
-  public static final String             CONFIGS             = "configs";
-  public static final String             CLUSTER_NAME        = "clusterName";
-  public static final String             PARTITIONS          = "partitions";
-  public static final String             RESOURCE_GROUP_NAME = "resourceGroupName";
-  public static final String             STATE_MODEL_DEF_REF = "stateModelDefRef";
-  public static final String             IDEAL_STATE_MODE    = "mode";
-
-  // zk commands
-  public static final String             ZK_DELETE_CHILDREN  = "zkDeleteChildren";
-
-  // extra json parameter map keys
-  public static final String             NEW_IDEAL_STATE     = "newIdealState";
-  public static final String             NEW_STATE_MODEL_DEF = "newStateModelDef";
-
-  // aliases for ClusterSetup commands
-  public static Map<String, Set<String>> CLUSTERSETUP_COMMAND_ALIASES;
-  static
-  {
-    CLUSTERSETUP_COMMAND_ALIASES = new HashMap<String, Set<String>>();
-    CLUSTERSETUP_COMMAND_ALIASES.put(ClusterSetup.addResource,
-                                     new HashSet<String>(Arrays.asList(new String[] { "addResourceGroup" })));
-    CLUSTERSETUP_COMMAND_ALIASES.put(ClusterSetup.activateCluster,
-                                     new HashSet<String>(Arrays.asList(new String[] { "enableStorageCluster" })));
-    CLUSTERSETUP_COMMAND_ALIASES.put(ClusterSetup.addInstance,
-                                     new HashSet<String>(Arrays.asList(new String[] { "addInstance" })));
-  }
-
-  // parameter map
-  final Map<String, String>              _parameterMap;
-
-  // extra parameters map
-  final Map<String, ZNRecord>            _extraParameterMap  =
-                                                                 new HashMap<String, ZNRecord>();
-
-  public JsonParameters(Representation entity) throws Exception
-  {
-    Form form = new Form(entity);
-
-    // get parameters in String format
-    String jsonPayload = form.getFirstValue(JSON_PARAMETERS, true);
-    if (jsonPayload == null || jsonPayload.isEmpty())
-    {
-      _parameterMap = Collections.emptyMap();
-    }
-    else
-    {
-      _parameterMap = ClusterRepresentationUtil.JsonToMap(jsonPayload);
-    }
-
-    // get extra parameters in ZNRecord format
-    ObjectMapper mapper = new ObjectMapper();
-    String newIdealStateString = form.getFirstValue(NEW_IDEAL_STATE, true);
-
-    if (newIdealStateString != null)
-    {
-      ZNRecord newIdealState =
-          mapper.readValue(new StringReader(newIdealStateString), ZNRecord.class);
-      _extraParameterMap.put(NEW_IDEAL_STATE, newIdealState);
-    }
-
-    String newStateModelString = form.getFirstValue(NEW_STATE_MODEL_DEF, true);
-    if (newStateModelString != null)
-    {
-      ZNRecord newStateModel =
-          mapper.readValue(new StringReader(newStateModelString), ZNRecord.class);
-      _extraParameterMap.put(NEW_STATE_MODEL_DEF, newStateModel);
-    }
-  }
-
-  public String getParameter(String key)
-  {
-    return _parameterMap.get(key);
-  }
-
-  public String getCommand()
-  {
-    String command = _parameterMap.get(MANAGEMENT_COMMAND); 
-    return command;
-  }
-
-  public ZNRecord getExtraParameter(String key)
-  {
-    return _extraParameterMap.get(key);
-  }
-
-  public Map<String, String> cloneParameterMap()
-  {
-    Map<String, String> parameterMap = new TreeMap<String, String>();
-    parameterMap.putAll(_parameterMap);
-    return parameterMap;
-  }
-
-  public void verifyCommand(String command)
-  {
-
-    // verify command itself
-    if (_parameterMap.isEmpty())
-    {
-      throw new HelixException("'" + JSON_PARAMETERS + "' in the POST body is empty");
-    }
-
-    if (!_parameterMap.containsKey(MANAGEMENT_COMMAND))
-    {
-      throw new HelixException("Missing management paramater '" + MANAGEMENT_COMMAND
-          + "'");
-    }
-
-    if (!_parameterMap.get(MANAGEMENT_COMMAND).equalsIgnoreCase(command)
-        && !(CLUSTERSETUP_COMMAND_ALIASES.get(command) != null && CLUSTERSETUP_COMMAND_ALIASES.get(command)
-                                                                                              .contains(_parameterMap.get(MANAGEMENT_COMMAND))))
-    {
-      throw new HelixException(MANAGEMENT_COMMAND + " must be '" + command + "'");
-    }
-
-    // verify command parameters
-    if (command.equalsIgnoreCase(ClusterSetup.enableInstance))
-    {
-      if (!_parameterMap.containsKey(ENABLED))
-      {
-        throw new HelixException("Missing Json parameters: '" + ENABLED + "'");
-      }
-    }
-    else if (command.equalsIgnoreCase(ClusterSetup.enablePartition))
-    {
-      if (!_parameterMap.containsKey(ENABLED))
-      {
-        throw new HelixException("Missing Json parameters: '" + ENABLED + "'");
-      }
-
-      if (!_parameterMap.containsKey(PARTITION))
-      {
-        throw new HelixException("Missing Json parameters: '" + PARTITION + "'");
-      }
-
-      if (!_parameterMap.containsKey(RESOURCE))
-      {
-        throw new HelixException("Missing Json parameters: '" + RESOURCE + "'");
-      }
-    }
-    else if (command.equalsIgnoreCase(ClusterSetup.resetPartition))
-    {
-      if (!_parameterMap.containsKey(PARTITION))
-      {
-        throw new HelixException("Missing Json parameters: '" + PARTITION + "'");
-      }
-
-      if (!_parameterMap.containsKey(RESOURCE))
-      {
-        throw new HelixException("Missing Json parameters: '" + RESOURCE + "'");
-      }
-    }
-    else if (command.equalsIgnoreCase(ClusterSetup.resetInstance))
-    {
-      // nothing
-    }
-    else if (command.equalsIgnoreCase(ClusterSetup.activateCluster))
-    {
-      if (!_parameterMap.containsKey(GRAND_CLUSTER))
-      {
-        throw new HelixException("Missing Json parameters: '" + GRAND_CLUSTER + "'");
-      }
-    }
-    else if (command.equalsIgnoreCase(ClusterSetup.setConfig))
-    {
-      if (!_parameterMap.containsKey(CONFIGS))
-      {
-        throw new HelixException("Missing Json parameters: '" + CONFIGS + "'");
-      }
-    }
-    else if (command.equalsIgnoreCase(ClusterSetup.removeConfig))
-    {
-      if (!_parameterMap.containsKey(CONFIGS))
-      {
-        throw new HelixException("Missing Json parameters: '" + CONFIGS + "'");
-      }
-    }
-    else if (command.equalsIgnoreCase(ClusterSetup.addCluster))
-    {
-      if (!_parameterMap.containsKey(CLUSTER_NAME))
-      {
-        throw new HelixException("Missing Json parameters: '" + CLUSTER_NAME + "'");
-      }
-    }
-    else if (command.equalsIgnoreCase(ClusterSetup.addResource))
-    {
-      if (!_parameterMap.containsKey(RESOURCE_GROUP_NAME))
-      {
-        throw new HelixException("Missing Json paramaters: '" + RESOURCE_GROUP_NAME + "'");
-      }
-
-      if (!_parameterMap.containsKey(PARTITIONS))
-      {
-        throw new HelixException("Missing Json paramaters: '" + PARTITIONS + "'");
-      }
-
-      if (!_parameterMap.containsKey(STATE_MODEL_DEF_REF))
-      {
-        throw new HelixException("Missing Json paramaters: '" + STATE_MODEL_DEF_REF + "'");
-      }
-
-    }
-  }
-
-  // temp test
-  public static void main(String[] args) throws Exception
-  {
-    String jsonPayload =
-        "{\"command\":\"resetPartition\",\"resource\": \"DB-1\",\"partition\":\"DB-1_22 DB-1_23\"}";
-    Map<String, String> map = ClusterRepresentationUtil.JsonToMap(jsonPayload);
-    System.out.println(map);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ResourceGroupResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ResourceGroupResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ResourceGroupResource.java
deleted file mode 100644
index 02fd82e..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ResourceGroupResource.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.data.Status;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.HelixException;
-import com.linkedin.helix.PropertyKey;
-import com.linkedin.helix.PropertyKey.Builder;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.tools.ClusterSetup;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class ResourceGroupResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(ResourceGroupResource.class);
-
-  public ResourceGroupResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return true;
-  }
-
-  @Override
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String resourceName = (String) getRequest().getAttributes().get("resourceName");
-      presentation = getIdealStateRepresentation(clusterName, resourceName);
-    }
-
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }
-    return presentation;
-  }
-
-  StringRepresentation getIdealStateRepresentation(String clusterName, String resourceName) throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
-    Builder keyBuilder = new PropertyKey.Builder(clusterName);
-    ZkClient zkClient =
-        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-
-    String message =
-        ClusterRepresentationUtil.getClusterPropertyAsString(zkClient,
-                                                             clusterName,
-                                                             keyBuilder.idealStates(resourceName),
-                                                             MediaType.APPLICATION_JSON);
-
-    StringRepresentation representation =
-        new StringRepresentation(message, MediaType.APPLICATION_JSON);
-
-    return representation;
-  }
-
-  @Override
-  public void removeRepresentations()
-  {
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String resourceGroupName =
-          (String) getRequest().getAttributes().get("resourceName");
-      ZkClient zkClient =
-          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-      
-      ClusterSetup setupTool = new ClusterSetup(zkClient);
-      setupTool.dropResourceFromCluster(clusterName, resourceGroupName);
-      getResponse().setStatus(Status.SUCCESS_OK);
-    }
-    catch (Exception e)
-    {
-      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
-                              MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-      LOG.error("", e);
-    }
-  }
-
-  @Override
-  public void acceptRepresentation(Representation entity)
-  {
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      String resourceName = (String) getRequest().getAttributes().get("resourceName");
-
-      JsonParameters jsonParameters = new JsonParameters(entity);
-      String command = jsonParameters.getCommand();
-      if (command.equalsIgnoreCase(ClusterSetup.resetResource))
-      {
-        ZkClient zkClient =
-            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-        ClusterSetup setupTool = new ClusterSetup(zkClient);
-        setupTool.getClusterManagementTool().resetResource(clusterName, Arrays.asList(resourceName));
-      }
-      else
-      {
-        throw new HelixException("Unsupported command: " + command
-                                 + ". Should be one of [" + ClusterSetup.resetResource + "]");
-      }
-    }
-    catch (Exception e)
-    {
-      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
-                              MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-      LOG.error("", e);
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ResourceGroupsResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ResourceGroupsResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ResourceGroupsResource.java
deleted file mode 100644
index da2e53a..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ResourceGroupsResource.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.data.Status;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.HelixException;
-import com.linkedin.helix.ZNRecord;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.model.IdealState.IdealStateModeProperty;
-import com.linkedin.helix.tools.ClusterSetup;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-public class ResourceGroupsResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(ResourceGroupsResource.class);
-
-  public ResourceGroupsResource(Context context, Request request, Response response)
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPost()
-  {
-    return true;
-  }
-
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-
-  @Override
-  public boolean allowDelete()
-  {
-    return false;
-  }
-
-  @Override
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-      presentation = getHostedEntitiesRepresentation(clusterName);
-    }
-
-    catch (Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }
-    return presentation;
-  }
-
-  StringRepresentation getHostedEntitiesRepresentation(String clusterName) throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
-    ZkClient zkClient =
-        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-    ;
-    ClusterSetup setupTool = new ClusterSetup(zkClient);
-    List<String> hostedEntities =
-        setupTool.getClusterManagementTool().getResourcesInCluster(clusterName);
-
-    ZNRecord hostedEntitiesRecord = new ZNRecord("ResourceGroups");
-    hostedEntitiesRecord.setListField("ResourceGroups", hostedEntities);
-
-    StringRepresentation representation =
-        new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(hostedEntitiesRecord),
-                                 MediaType.APPLICATION_JSON);
-
-    return representation;
-  }
-
-  @Override
-  public void acceptRepresentation(Representation entity)
-  {
-    try
-    {
-      String clusterName = (String) getRequest().getAttributes().get("clusterName");
-
-      JsonParameters jsonParameters = new JsonParameters(entity);
-      String command = jsonParameters.getCommand();
-
-      if (command.equalsIgnoreCase(ClusterSetup.addResource)
-          || JsonParameters.CLUSTERSETUP_COMMAND_ALIASES.get(ClusterSetup.addResource)
-                                                        .contains(command))
-      {
-        jsonParameters.verifyCommand(ClusterSetup.addResource);
-
-        String entityName =
-            jsonParameters.getParameter(JsonParameters.RESOURCE_GROUP_NAME);
-        String stateModelDefRef =
-            jsonParameters.getParameter(JsonParameters.STATE_MODEL_DEF_REF);
-        int partitions =
-            Integer.parseInt(jsonParameters.getParameter(JsonParameters.PARTITIONS));
-        String mode = IdealStateModeProperty.AUTO.toString();
-        if (jsonParameters.getParameter(JsonParameters.IDEAL_STATE_MODE) != null)
-        {
-          mode = jsonParameters.getParameter(JsonParameters.IDEAL_STATE_MODE);
-        }
-
-        ZkClient zkClient =
-            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-        ;
-        ClusterSetup setupTool = new ClusterSetup(zkClient);
-        setupTool.addResourceToCluster(clusterName,
-                                       entityName,
-                                       partitions,
-                                       stateModelDefRef,
-                                       mode);
-      }
-      else
-      {
-        throw new HelixException("Unsupported command: " + command
-            + ". Should be one of [" + ClusterSetup.addResource + "]");
-
-      }
-
-      getResponse().setEntity(getHostedEntitiesRepresentation(clusterName));
-      getResponse().setStatus(Status.SUCCESS_OK);
-    }
-
-    catch (Exception e)
-    {
-      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
-                              MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-      LOG.error("Error in posting " + entity, e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/SchedulerTasksResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/SchedulerTasksResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/SchedulerTasksResource.java
deleted file mode 100644
index 61e0514..0000000
--- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/SchedulerTasksResource.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.linkedin.helix.webapp.resources;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.Form;
-import org.restlet.data.MediaType;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.data.Status;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.HelixDataAccessor;
-import com.linkedin.helix.HelixException;
-import com.linkedin.helix.InstanceType;
-import com.linkedin.helix.PropertyPathConfig;
-import com.linkedin.helix.PropertyType;
-import com.linkedin.helix.manager.zk.ZkClient;
-import com.linkedin.helix.model.LiveInstance;
-import com.linkedin.helix.model.Message;
-import com.linkedin.helix.model.Message.MessageType;
-import com.linkedin.helix.tools.ClusterSetup;
-import com.linkedin.helix.webapp.RestAdminApplication;
-
-/**
- * This resource can be used to send scheduler tasks to the controller.
- * 
- * */
-public class SchedulerTasksResource extends Resource
-{
-  private final static Logger LOG = Logger.getLogger(SchedulerTasksResource.class);
-
-  public static String CRITERIA = "Criteria";
-  public static String MESSAGETEMPLATE = "MessageTemplate";
-  public SchedulerTasksResource(Context context,
-          Request request,
-          Response response) 
-  {
-    super(context, request, response);
-    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-  }
-
-  @Override
-  public boolean allowGet()
-  {
-    return true;
-  }
-  
-  @Override
-  public boolean allowPost()
-  {
-    return true;
-  }
-  
-  @Override
-  public boolean allowPut()
-  {
-    return false;
-  }
-  
-  @Override
-  public boolean allowDelete()
-  {
-    return false;
-  }
-  
-  @Override
-  public Representation represent(Variant variant)
-  {
-    StringRepresentation presentation = null;
-    try
-    {
-      presentation = getSchedulerTasksRepresentation();
-    }
-    
-    catch(Exception e)
-    {
-      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
-      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
-
-      LOG.error("", e);
-    }  
-    return presentation;
-  }
-  
-  StringRepresentation getSchedulerTasksRepresentation() throws JsonGenerationException, JsonMappingException, IOException
-  {
-    String clusterName = (String)getRequest().getAttributes().get("clusterName");
-    String instanceName = (String)getRequest().getAttributes().get("instanceName");
-    ZkClient zkClient = (ZkClient)getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-    ClusterSetup setupTool = new ClusterSetup(zkClient);
-    List<String> instances = setupTool.getClusterManagementTool().getInstancesInCluster(clusterName);
-    
-    HelixDataAccessor accessor = ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
-    LiveInstance liveInstance = accessor.getProperty(accessor.keyBuilder().liveInstance(instanceName));
-    String sessionId = liveInstance.getSessionId();
-    
-    StringRepresentation representation = new StringRepresentation("");//(ClusterRepresentationUtil.ObjectToJson(instanceConfigs), MediaType.APPLICATION_JSON);
-    
-    return representation;
-  }
-  
-  @Override
-  public void acceptRepresentation(Representation entity)
-  {
-    try
-    {
-      String clusterName = (String)getRequest().getAttributes().get("clusterName");
-      Form form = new Form(entity);
-      ZkClient zkClient = (ZkClient)getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
-      
-      String msgTemplateString = ClusterRepresentationUtil.getFormJsonParameterString(form, MESSAGETEMPLATE);
-      if(msgTemplateString == null)
-      {
-        throw new HelixException("SchedulerTasksResource need to have MessageTemplate specified.");
-      }
-      Map<String, String> messageTemplate = ClusterRepresentationUtil.getFormJsonParameters(form, MESSAGETEMPLATE);
-      
-      String criteriaString = ClusterRepresentationUtil.getFormJsonParameterString(form, CRITERIA);
-      if(criteriaString == null)
-      {
-        throw new HelixException("SchedulerTasksResource need to have Criteria specified.");
-      }
-      
-      Message schedulerMessage = new Message(MessageType.SCHEDULER_MSG, UUID.randomUUID().toString());
-      schedulerMessage.getRecord().getSimpleFields().put(CRITERIA, criteriaString);
-      
-      schedulerMessage.getRecord().getMapFields().put(MESSAGETEMPLATE, messageTemplate);
-      
-      schedulerMessage.setTgtSessionId("*");
-      schedulerMessage.setTgtName("CONTROLLER");
-      schedulerMessage.setSrcInstanceType(InstanceType.CONTROLLER);
-      
-      HelixDataAccessor accessor = ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
-      accessor.setProperty(accessor.keyBuilder().controllerMessage(schedulerMessage.getMsgId()), schedulerMessage);
-      
-      Map<String, String> resultMap = new HashMap<String, String>();
-      resultMap.put("StatusUpdatePath", PropertyPathConfig.getPath(PropertyType.STATUSUPDATES_CONTROLLER, clusterName, MessageType.SCHEDULER_MSG.toString(),schedulerMessage.getMsgId()));
-      resultMap.put("MessageType", Message.MessageType.SCHEDULER_MSG.toString());
-      resultMap.put("MsgId", schedulerMessage.getMsgId());
-      
-      // Assemble the rest URL for task status update
-      String ipAddress = InetAddress.getLocalHost().getCanonicalHostName();
-      String url = "http://" + ipAddress+":" + getContext().getAttributes().get(RestAdminApplication.PORT)
-          + "/clusters/" + clusterName+"/Controller/statusUpdates/SCHEDULER_MSG/" + schedulerMessage.getMsgId();
-      resultMap.put("statusUpdateUrl", url);
-      
-      getResponse().setEntity(ClusterRepresentationUtil.ObjectToJson(resultMap), MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-    }
-    catch(Exception e)
-    {
-      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
-          MediaType.APPLICATION_JSON);
-      getResponse().setStatus(Status.SUCCESS_OK);
-      LOG.error("", e);
-    }  
-  }
-}