Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Solve #1536, Define interface to query node info of SSM cluster (#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
littlezhou authored Jan 15, 2018
1 parent 5ced01d commit 682435e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
11 changes: 11 additions & 0 deletions smart-engine/src/main/java/org/smartdata/server/SmartEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.smartdata.conf.SmartConf;
import org.smartdata.model.StorageCapacity;
import org.smartdata.model.Utilization;
import org.smartdata.server.cluster.NodeInfo;
import org.smartdata.server.engine.ActiveServerInfo;
import org.smartdata.server.engine.CmdletManager;
import org.smartdata.server.engine.ConfManager;
import org.smartdata.server.engine.RuleManager;
Expand All @@ -36,6 +38,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;

Expand Down Expand Up @@ -176,4 +179,12 @@ private List<Utilization> getFackData(String resourceName, long granularity,
}
return utils;
}

public List<NodeInfo> getSsmNodesInfo() {
List<NodeInfo> ret = new LinkedList<>();
ret.addAll(Arrays.asList(ActiveServerInfo.getInstance()));
ret.addAll(getStandbyServers());
ret.addAll(getAgents());
return ret;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public CmdletDispatcher(SmartContext smartContext, CmdletManager cmdletManager,
boolean disableLocal = smartContext.getConf().getBoolean(
SmartConfKeys.SMART_ACTION_LOCAL_EXECUTION_DISABLED_KEY,
SmartConfKeys.SMART_ACTION_LOCAL_EXECUTION_DISABLED_DEFAULT);
CmdletExecutorService exe =
new LocalCmdletExecutorService(smartContext.getConf(), cmdletManager);
if (!disableLocal) {
CmdletExecutorService exe =
new LocalCmdletExecutorService(smartContext.getConf(), cmdletManager);
registerExecutorService(exe);
}
this.index = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ public Response fileInfo(String path) {
}
}

@GET
@Path("/primary/ssmnodesinfo")
public Response ssmNodesInfo() {
try {
return new JsonResponse<>(Response.Status.OK, smartEngine.getSsmNodesInfo()).build();
} catch (Exception e) {
logger.error("Exception in ClusterRestApi while listing SSM nodes", e);
return new JsonResponse<>(Response.Status.INTERNAL_SERVER_ERROR,
e.getMessage(), ExceptionUtils.getStackTrace(e)).build();
}
}

// @GET
// @Path("/alluxio/{clusterName}")
// public void alluxio() {
Expand Down

0 comments on commit 682435e

Please sign in to comment.