You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by go...@apache.org on 2016/08/25 20:19:43 UTC
[14/46] incubator-slider git commit: SLIDER-1165 Create
yarn-native-services branch on Slider corresponding to the
yarn-native-services branch on Hadoop
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResouceContentCacheFactory.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResouceContentCacheFactory.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResouceContentCacheFactory.java
deleted file mode 100644
index 2facf16..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResouceContentCacheFactory.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application;
-
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-import org.apache.slider.server.appmaster.web.rest.application.resources.AggregateModelRefresher;
-import org.apache.slider.server.appmaster.web.rest.application.resources.AppconfRefresher;
-import org.apache.slider.server.appmaster.web.rest.application.resources.CachedContent;
-import org.apache.slider.server.appmaster.web.rest.application.resources.ContentCache;
-import org.apache.slider.server.appmaster.web.rest.application.resources.LiveComponentsRefresher;
-import org.apache.slider.server.appmaster.web.rest.application.resources.LiveContainersRefresher;
-import org.apache.slider.server.appmaster.web.rest.application.resources.LiveNodesRefresher;
-import org.apache.slider.server.appmaster.web.rest.application.resources.LiveResourcesRefresher;
-import org.apache.slider.server.appmaster.web.rest.application.resources.LiveStatisticsRefresher;
-
-import static org.apache.slider.server.appmaster.web.rest.RestPaths.*;
-
-public class ApplicationResouceContentCacheFactory {
- public static final int LIFESPAN = 500;
-
- /**
- * Build the content cache
- * @param state state view
- */
- public static ContentCache createContentCache(
- StateAccessForProviders state) {
- ContentCache cache = new ContentCache();
- cache.put(LIVE_RESOURCES, new CachedContent<>(LIFESPAN, new LiveResourcesRefresher(state)));
- cache.put(LIVE_CONTAINERS, new CachedContent<>(LIFESPAN, new LiveContainersRefresher(state)));
- cache.put(LIVE_COMPONENTS, new CachedContent<>(LIFESPAN, new LiveComponentsRefresher(state)));
- cache.put(LIVE_NODES, new CachedContent<>(LIFESPAN, new LiveNodesRefresher(state)));
- cache.put(MODEL_DESIRED,
- new CachedContent<>(LIFESPAN, new AggregateModelRefresher(state, false)));
- cache.put(MODEL_RESOLVED,
- new CachedContent<>(LIFESPAN, new AggregateModelRefresher(state, true)));
- cache.put(MODEL_RESOLVED_APPCONF,
- new CachedContent<>(LIFESPAN, new AppconfRefresher(state, false, false)));
- cache.put(MODEL_RESOLVED_RESOURCES,
- new CachedContent<>(LIFESPAN, new AppconfRefresher(state, false, true)));
- cache.put(MODEL_DESIRED_APPCONF,
- new CachedContent<>(LIFESPAN, new AppconfRefresher(state, true, false)));
- cache.put(MODEL_DESIRED_RESOURCES,
- new CachedContent<>(LIFESPAN, new AppconfRefresher(state, true, true)));
- cache.put(LIVE_STATISTICS, new CachedContent<>(LIFESPAN, new LiveStatisticsRefresher(state)));
- return cache;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java
deleted file mode 100644
index 52068d6..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application;
-
-import com.google.common.collect.Lists;
-import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.apache.hadoop.yarn.webapp.BadRequestException;
-import org.apache.hadoop.yarn.webapp.NotFoundException;
-import org.apache.slider.api.types.ApplicationLivenessInformation;
-import org.apache.slider.api.types.ComponentInformation;
-import org.apache.slider.api.types.ContainerInformation;
-import org.apache.slider.api.types.NodeInformation;
-import org.apache.slider.api.types.NodeInformationList;
-import org.apache.slider.core.conf.AggregateConf;
-import org.apache.slider.core.conf.ConfTree;
-import org.apache.slider.core.exceptions.NoSuchNodeException;
-import org.apache.slider.core.persist.ConfTreeSerDeser;
-import org.apache.slider.server.appmaster.actions.ActionFlexCluster;
-import org.apache.slider.server.appmaster.actions.AsyncAction;
-import org.apache.slider.server.appmaster.actions.QueueAccess;
-import org.apache.slider.server.appmaster.state.RoleInstance;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-import org.apache.slider.server.appmaster.web.WebAppApi;
-import org.apache.slider.server.appmaster.web.rest.AbstractSliderResource;
-import static org.apache.slider.server.appmaster.web.rest.RestPaths.*;
-
-import org.apache.slider.server.appmaster.web.rest.application.actions.RestActionStop;
-import org.apache.slider.server.appmaster.web.rest.application.actions.StopResponse;
-import org.apache.slider.server.appmaster.web.rest.application.resources.ContentCache;
-import org.apache.slider.server.appmaster.web.rest.application.actions.RestActionPing;
-import org.apache.slider.api.types.PingInformation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Singleton;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-
-import static javax.ws.rs.core.MediaType.*;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-@Singleton
-@SuppressWarnings("unchecked")
-public class ApplicationResource extends AbstractSliderResource {
- private static final Logger log =
- LoggerFactory.getLogger(ApplicationResource.class);
-
- public static final List<String> LIVE_ENTRIES = toJsonList("resources",
- "containers",
- "components",
- "nodes",
- "statistics",
- "internal");
-
- public static final List<String> ROOT_ENTRIES =
- toJsonList("model", "live", "actions");
-
- public static final List<String> MODEL_ENTRIES =
- toJsonList("desired", "resolved");
-
- /**
- * This is the cache of all content ... each entry is
- * designed to be self-refreshing on get operations,
- * so is never very out of date, yet many GETs don't
- * overload the rest of the system.
- */
- private final ContentCache cache;
- private final StateAccessForProviders state;
- private final QueueAccess actionQueues;
-
- public ApplicationResource(WebAppApi slider) {
- super(slider);
- state = slider.getAppState();
- cache = slider.getContentCache();
- actionQueues = slider.getQueues();
- }
-
- /**
- * Build a new JSON-marshallable list of string elements
- * @param elements elements
- * @return something that can be returned
- */
- private static List<String> toJsonList(String... elements) {
- return Lists.newArrayList(elements);
- }
-
- @GET
- @Path("/")
- @Produces({APPLICATION_JSON})
- public List<String> getRoot() {
- markGet(SLIDER_SUBPATH_APPLICATION);
- return ROOT_ENTRIES;
- }
-
- /**
- * Enum model values: desired and resolved
- * @return the desired and resolved model
- */
- @GET
- @Path(MODEL)
- @Produces({APPLICATION_JSON})
- public List<String> getModel() {
- markGet(SLIDER_SUBPATH_APPLICATION, MODEL);
- return MODEL_ENTRIES;
- }
-
- @GET
- @Path(MODEL_DESIRED)
- @Produces({APPLICATION_JSON})
- public AggregateConf getModelDesired() {
- markGet(SLIDER_SUBPATH_APPLICATION, MODEL_DESIRED);
- return lookupAggregateConf(MODEL_DESIRED);
- }
-
- @GET
- @Path(MODEL_DESIRED_APPCONF)
- @Produces({APPLICATION_JSON})
- public ConfTree getModelDesiredAppconf() {
- markGet(SLIDER_SUBPATH_APPLICATION, MODEL_DESIRED_APPCONF);
- return lookupConfTree(MODEL_DESIRED_APPCONF);
- }
-
- @GET
- @Path(MODEL_DESIRED_RESOURCES)
- @Produces({APPLICATION_JSON})
- public ConfTree getModelDesiredResources() {
- markGet(SLIDER_SUBPATH_APPLICATION, MODEL_DESIRED_RESOURCES);
- return lookupConfTree(MODEL_DESIRED_RESOURCES);
- }
-
-/*
- @PUT
- @Path(MODEL_DESIRED_RESOURCES)
-// @Consumes({APPLICATION_JSON, TEXT_PLAIN})
- @Consumes({TEXT_PLAIN})
- @Produces({APPLICATION_JSON})
-*/
- public ConfTree setModelDesiredResources(
- String json) {
- markPut(SLIDER_SUBPATH_APPLICATION, MODEL_DESIRED_RESOURCES);
- int size = json != null ? json.length() : 0;
- log.info("PUT {} {} bytes:\n{}", MODEL_DESIRED_RESOURCES,
- size,
- json);
- if (size == 0) {
- log.warn("No JSON in PUT request; rejecting");
- throw new BadRequestException("No JSON in PUT");
- }
-
- try {
- ConfTreeSerDeser serDeser = new ConfTreeSerDeser();
- ConfTree updated = serDeser.fromJson(json);
- queue(new ActionFlexCluster("flex",
- 1, TimeUnit.MILLISECONDS,
- updated));
- // return the updated value, even though it potentially hasn't yet
- // been executed
- return updated;
- } catch (Exception e) {
- throw buildException("PUT to "+ MODEL_DESIRED_RESOURCES , e);
- }
- }
- @PUT
- @Path(MODEL_DESIRED_RESOURCES)
- @Consumes({APPLICATION_JSON})
- @Produces({APPLICATION_JSON})
- public ConfTree setModelDesiredResources(
- ConfTree updated) {
- try {
- queue(new ActionFlexCluster("flex",
- 1, TimeUnit.MILLISECONDS,
- updated));
- // return the updated value, even though it potentially hasn't yet
- // been executed
- return updated;
- } catch (Exception e) {
- throw buildException("PUT to "+ MODEL_DESIRED_RESOURCES , e);
- }
- }
-
-
-
- @GET
- @Path(MODEL_RESOLVED)
- @Produces({APPLICATION_JSON})
- public AggregateConf getModelResolved() {
- markGet(SLIDER_SUBPATH_APPLICATION, MODEL_RESOLVED);
- return lookupAggregateConf(MODEL_RESOLVED);
- }
-
- @GET
- @Path(MODEL_RESOLVED_APPCONF)
- @Produces({APPLICATION_JSON})
- public ConfTree getModelResolvedAppconf() {
- markGet(SLIDER_SUBPATH_APPLICATION, MODEL_RESOLVED_APPCONF);
- return lookupConfTree(MODEL_RESOLVED_APPCONF);
- }
-
- @GET
- @Path(MODEL_RESOLVED_RESOURCES)
- @Produces({APPLICATION_JSON})
- public ConfTree getModelResolvedResources() {
- markGet(SLIDER_SUBPATH_APPLICATION, MODEL_RESOLVED_RESOURCES);
- return lookupConfTree(MODEL_RESOLVED_RESOURCES);
- }
-
- @GET
- @Path(LIVE)
- @Produces({APPLICATION_JSON})
- public List<String> getLive() {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE);
- return LIVE_ENTRIES;
- }
-
- @GET
- @Path(LIVE_RESOURCES)
- @Produces({APPLICATION_JSON})
- public ConfTree getLiveResources() {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_RESOURCES);
- return lookupConfTree(LIVE_RESOURCES);
- }
-
- @GET
- @Path(LIVE_CONTAINERS)
- @Produces({APPLICATION_JSON})
- public Map<String, ContainerInformation> getLiveContainers() {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_CONTAINERS);
- try {
- return (Map<String, ContainerInformation>)cache.lookup(
- LIVE_CONTAINERS);
- } catch (Exception e) {
- throw buildException(LIVE_CONTAINERS, e);
- }
- }
-
- @GET
- @Path(LIVE_CONTAINERS + "/{containerId}")
- @Produces({APPLICATION_JSON})
- public ContainerInformation getLiveContainer(
- @PathParam("containerId") String containerId) {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_CONTAINERS);
- try {
- RoleInstance id = state.getLiveInstanceByContainerID(containerId);
- return id.serialize();
- } catch (NoSuchNodeException e) {
- throw new NotFoundException("Unknown container: " + containerId);
- } catch (Exception e) {
- throw buildException(LIVE_CONTAINERS + "/"+ containerId, e);
- }
- }
-
- @GET
- @Path(LIVE_COMPONENTS)
- @Produces({APPLICATION_JSON})
- public Map<String, ComponentInformation> getLiveComponents() {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_COMPONENTS);
- try {
- return (Map<String, ComponentInformation>) cache.lookup(LIVE_COMPONENTS);
- } catch (Exception e) {
- throw buildException(LIVE_COMPONENTS, e);
- }
- }
-
- @GET
- @Path(LIVE_COMPONENTS + "/{component}")
- @Produces({APPLICATION_JSON})
- public ComponentInformation getLiveComponent(
- @PathParam("component") String component) {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_COMPONENTS);
- try {
- return state.getComponentInformation(component);
- } catch (YarnRuntimeException e) {
- throw new NotFoundException("Unknown component: " + component);
- } catch (Exception e) {
- throw buildException(LIVE_CONTAINERS +"/" + component, e);
- }
- }
-
- /**
- * Liveness information for the application as a whole
- * @return snapshot of liveness
- */
- @GET
- @Path(LIVE_LIVENESS)
- @Produces({APPLICATION_JSON})
- public ApplicationLivenessInformation getLivenessInformation() {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_LIVENESS);
- try {
- return state.getApplicationLivenessInformation();
- } catch (Exception e) {
- throw buildException(LIVE_CONTAINERS, e);
- }
- }
-
-/*
-TODO: decide what structure to return here, then implement
-
- @GET
- @Path(LIVE_LIVENESS + "/{component}")
- @Produces({APPLICATION_JSON})
- public ApplicationLivenessInformation getLivenessForComponent(
- @PathParam("component") String component) {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_COMPONENTS);
- try {
- RoleStatus roleStatus = state.lookupRoleStatus(component);
- ApplicationLivenessInformation info = new ApplicationLivenessInformation();
- info.requested = roleStatus.getRequested();
- info.allRequestsSatisfied = info.requested == 0;
- return info;
- } catch (YarnRuntimeException e) {
- throw new NotFoundException("Unknown component: " + component);
- } catch (Exception e) {
- throw buildException(LIVE_LIVENESS + "/" + component, e);
- }
- }
-*/
-
-
- @GET
- @Path(LIVE_NODES)
- @Produces({APPLICATION_JSON})
- public NodeInformationList getLiveNodes() {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_COMPONENTS);
- try {
- return (NodeInformationList) cache.lookup(LIVE_NODES);
- } catch (Exception e) {
- throw buildException(LIVE_COMPONENTS, e);
- }
- }
-
- @GET
- @Path(LIVE_NODES + "/{hostname}")
- @Produces({APPLICATION_JSON})
- public NodeInformation getLiveNode(@PathParam("hostname") String hostname) {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_COMPONENTS);
- try {
- NodeInformation ni = state.getNodeInformation(hostname);
- if (ni != null) {
- return ni;
- } else {
- throw new NotFoundException("Unknown node: " + hostname);
- }
- } catch (NotFoundException e) {
- throw e;
- } catch (Exception e) {
- throw buildException(LIVE_COMPONENTS + "/" + hostname, e);
- }
- }
-
- /**
- * Statistics of the application
- * @return snapshot statistics
- */
- @GET
- @Path(LIVE_STATISTICS)
- @Produces({APPLICATION_JSON})
- public Map<String, Integer> getLiveStatistics() {
- markGet(SLIDER_SUBPATH_APPLICATION, LIVE_LIVENESS);
- try {
- return (Map<String, Integer>) cache.lookup(LIVE_STATISTICS);
- } catch (Exception e) {
- throw buildException(LIVE_STATISTICS, e);
- }
- }
-
- /**
- * Helper method; look up an aggregate configuration in the cache from
- * a key, or raise an exception
- * @param key key to resolve
- * @return the configuration
- * @throws WebApplicationException on a failure
- */
- protected AggregateConf lookupAggregateConf(String key) {
- try {
- return (AggregateConf) cache.lookup(key);
- } catch (Exception e) {
- throw buildException(key, e);
- }
- }
-
-
- /**
- * Helper method; look up an conf tree in the cache from
- * a key, or raise an exception
- * @param key key to resolve
- * @return the configuration
- * @throws WebApplicationException on a failure
- */
- protected ConfTree lookupConfTree(String key) {
- try {
- return (ConfTree) cache.lookup(key);
- } catch (Exception e) {
- throw buildException(key, e);
- }
- }
-
- /* ************************************************************************
-
- ACTION PING
-
- **************************************************************************/
-
- @GET
- @Path(ACTION_PING)
- @Produces({APPLICATION_JSON})
- public PingInformation actionPingGet(@Context HttpServletRequest request,
- @Context UriInfo uriInfo) {
- markGet(SLIDER_SUBPATH_APPLICATION, ACTION_PING);
- return new RestActionPing().ping(request, uriInfo, "");
- }
-
- @POST
- @Path(ACTION_PING)
- @Produces({APPLICATION_JSON})
- public PingInformation actionPingPost(@Context HttpServletRequest request,
- @Context UriInfo uriInfo,
- String body) {
- markPost(SLIDER_SUBPATH_APPLICATION, ACTION_PING);
- return new RestActionPing().ping(request, uriInfo, body);
- }
-
- @PUT
- @Path(ACTION_PING)
- @Consumes({TEXT_PLAIN})
- @Produces({APPLICATION_JSON})
- public PingInformation actionPingPut(@Context HttpServletRequest request,
- @Context UriInfo uriInfo,
- String body) {
- markPut(SLIDER_SUBPATH_APPLICATION, ACTION_PING);
- return new RestActionPing().ping(request, uriInfo, body);
- }
-
- @DELETE
- @Path(ACTION_PING)
- @Consumes({APPLICATION_JSON})
- @Produces({APPLICATION_JSON})
- public PingInformation actionPingDelete(@Context HttpServletRequest request,
- @Context UriInfo uriInfo) {
- markDelete(SLIDER_SUBPATH_APPLICATION, ACTION_PING);
- return new RestActionPing().ping(request, uriInfo, "");
- }
-
- @HEAD
- @Path(ACTION_PING)
- public Object actionPingHead(@Context HttpServletRequest request,
- @Context UriInfo uriInfo) {
- mark("HEAD", SLIDER_SUBPATH_APPLICATION, ACTION_PING);
- return new RestActionPing().ping(request, uriInfo, "");
- }
-
- /* ************************************************************************
-
- ACTION STOP
-
- **************************************************************************/
-
-
- @POST
- @Path(ACTION_STOP)
- @Produces({APPLICATION_JSON})
- public StopResponse actionStop(@Context HttpServletRequest request,
- @Context UriInfo uriInfo,
- String body) {
- markPost(SLIDER_SUBPATH_APPLICATION, ACTION_STOP);
- return new RestActionStop(slider).stop(request, uriInfo, body);
- }
-
- /**
- * Schedule an action
- * @param action for delayed execution
- */
- public void schedule(AsyncAction action) {
- actionQueues.schedule(action);
- }
-
- /**
- * Put an action on the immediate queue -to be executed when the queue
- * reaches it.
- * @param action action to queue
- */
- public void queue(AsyncAction action) {
- actionQueues.put(action);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionPing.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionPing.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionPing.java
deleted file mode 100644
index 96b4f75..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionPing.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.actions;
-
-import org.apache.slider.api.types.PingInformation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.UriInfo;
-import java.util.Locale;
-
-public class RestActionPing {
- private static final Logger log =
- LoggerFactory.getLogger(RestActionPing.class);
-
- public RestActionPing() {
- }
-
- public PingInformation ping(HttpServletRequest request, UriInfo uriInfo, String body) {
- String verb = request.getMethod();
- log.info("Ping {}", verb);
- PingInformation pingInformation = new PingInformation();
- pingInformation.time = System.currentTimeMillis();
- pingInformation.verb = verb;
- pingInformation.body = body;
- String text =
- String.format(Locale.ENGLISH,
- "Ping verb %s received at %tc",
- verb, pingInformation.time);
- pingInformation.text = text;
- return pingInformation;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionStop.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionStop.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionStop.java
deleted file mode 100644
index 544f589..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionStop.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.actions;
-
-import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
-import org.apache.slider.core.main.LauncherExitCodes;
-import org.apache.slider.server.appmaster.actions.ActionStopSlider;
-import org.apache.slider.server.appmaster.web.WebAppApi;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.UriInfo;
-import java.util.Locale;
-import java.util.concurrent.TimeUnit;
-
-public class RestActionStop {
- private static final Logger log =
- LoggerFactory.getLogger(RestActionStop.class);
-
- private final WebAppApi slider;
-
- public RestActionStop(WebAppApi slider) {
- this.slider = slider;
- }
-
- public StopResponse stop(HttpServletRequest request, UriInfo uriInfo, String body) {
- String verb = request.getMethod();
- log.info("Ping {}", verb);
- StopResponse response = new StopResponse();
- response.verb = verb;
- long time = System.currentTimeMillis();
- String text =
- String.format(Locale.ENGLISH,
- "Stopping action %s received at %tc",
- verb, time);
- response.text = text;
- log.info(text);
- ActionStopSlider stopSlider =
- new ActionStopSlider(text,
- 1000,
- TimeUnit.MILLISECONDS,
- LauncherExitCodes.EXIT_SUCCESS,
- FinalApplicationStatus.SUCCEEDED,
- text);
- log.info("SliderAppMasterApi.stopCluster: {}", stopSlider);
- slider.getQueues().schedule(stopSlider);
-
- return response;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/StopResponse.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/StopResponse.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/StopResponse.java
deleted file mode 100644
index 9af6a22..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/StopResponse.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.actions;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class StopResponse {
- String verb;
- public String text;
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/package-info.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/package-info.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/package-info.java
deleted file mode 100644
index 34eb82c..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-/**
- * This package contains resources related to the application
- * REST API
- */
-package org.apache.slider.server.appmaster.web.rest.application;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/AggregateModelRefresher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/AggregateModelRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/AggregateModelRefresher.java
deleted file mode 100644
index ee28abf..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/AggregateModelRefresher.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import org.apache.slider.core.conf.AggregateConf;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-
-/**
- * Refresh the aggregate desired model via
- * {@link StateAccessForProviders#getInstanceDefinitionSnapshot()}
- */
-public class AggregateModelRefresher
- implements ResourceRefresher<AggregateConf> {
-
- private final StateAccessForProviders state;
- private final boolean resolved;
-
- public AggregateModelRefresher(StateAccessForProviders state,
- boolean resolved) {
- this.state = state;
- this.resolved = resolved;
- }
-
- @Override
- public AggregateConf refresh() throws Exception {
- return
- resolved ?
- state.getInstanceDefinitionSnapshot()
- : state.getUnresolvedInstanceDefinition();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/AppconfRefresher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/AppconfRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/AppconfRefresher.java
deleted file mode 100644
index 06460cc..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/AppconfRefresher.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import org.apache.slider.core.conf.AggregateConf;
-import org.apache.slider.core.conf.ConfTree;
-import org.apache.slider.core.persist.ConfTreeSerDeser;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-
-/**
- * refresher for resources and application configuration
- */
-public class AppconfRefresher
- implements ResourceRefresher<ConfTree> {
-
- private final StateAccessForProviders state;
- private final boolean unresolved;
- private final boolean resources;
-
- public AppconfRefresher(StateAccessForProviders state,
- boolean unresolved,
- boolean resources) {
- this.state = state;
- this.unresolved = unresolved;
- this.resources = resources;
- }
-
-
- @Override
- public ConfTree refresh() throws Exception {
- AggregateConf aggregateConf =
- unresolved ?
- state.getUnresolvedInstanceDefinition():
- state.getInstanceDefinitionSnapshot();
- ConfTree ct = resources ? aggregateConf.getResources()
- : aggregateConf.getAppConf();
- return new ConfTreeSerDeser().fromInstance(ct);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/CachedContent.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/CachedContent.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/CachedContent.java
deleted file mode 100644
index 22fd0fe..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/CachedContent.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.util.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A cached resource is one that can be stored and served up, with a refresh
- * only taking place when the expiry happens.
- *
- * The refresh check/refresh is synchronized.
- * @param <T> type to return
- */
-public class CachedContent<T> {
- private static final Logger log =
- LoggerFactory.getLogger(CachedContent.class);
- private T cachedValue;
- private long expires;
- private final long lifespan;
- private final ResourceRefresher<T> refresh;
- private int refreshCounter;
-
- public CachedContent(long lifespan,
- ResourceRefresher<T> refresh) {
- this.lifespan = lifespan;
- this.refresh = refresh;
- }
-
- /**
- * Get the value, triggering a refresh if needed
- * @return the cached or latest value.
- */
- public T get() throws Exception {
- maybeRefresh();
- return getCachedValue();
- }
-
- /**
- * Get the cached value without any expiry check
- * @return the last value set. May be null.
- */
- public synchronized T getCachedValue() {
- return cachedValue;
- }
-
- public synchronized int getRefreshCounter() {
- return refreshCounter;
- }
-
- /**
- * Get the lifespan in millis of the cached value
- * @return the lifespan
- */
- public long getLifespan() {
- return lifespan;
- }
-
- /**
- * Maybe refresh the content
- * @return true if a refresh took place.
- */
- public synchronized boolean maybeRefresh() throws Exception {
- long now = now();
- if (cachedValue == null || now >= expires) {
- log.debug("Refreshing at time {}", now);
- forceRefresh();
- log.debug("Refreshed value now {}", cachedValue);
- return true;
- }
- return false;
- }
-
- protected long now() {
- return Time.monotonicNow();
- }
-
- /**
- * Force a refresh and reset the expiry counter
- * @return the new value
- */
- protected synchronized T forceRefresh() throws Exception {
- refreshCounter ++;
- T updated = refresh.refresh();
- Preconditions.checkNotNull(updated);
- cachedValue = updated;
- expires = now() + lifespan;
- return cachedValue;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("CachedContent{");
- sb.append(" expires=").append(expires);
- sb.append(", lifespan=").append(lifespan);
- sb.append(", refresh=").append(refresh);
- sb.append(", refreshCounter=").append(refreshCounter);
- sb.append(", cached=").append(cachedValue);
- sb.append('}');
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ContentCache.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ContentCache.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ContentCache.java
deleted file mode 100644
index 8f026a1..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ContentCache.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Cache of content
- */
-public class ContentCache extends ConcurrentHashMap<String, CachedContent> {
-
- public ContentCache(int initialCapacity) {
- super(initialCapacity);
- }
-
- public ContentCache() {
- }
-
-
- public Object lookup(String key) throws Exception {
- CachedContent content = get(key);
- if (content == null) {
- throw new FileNotFoundException("no content for path " + key);
- }
- return content.get();
- }
-
-
- /**
- * Lookup a cached item. If an exception is raised on the refresh...
- * <ol>
- * <li>IOExceptions are thrown directly</li>
- * <li>Other exceptions are wrapped with an IOExceptions</li>
- * </ol>
- * @param key
- * @return
- * @throws IOException
- */
- public Object lookupWithIOE(String key) throws IOException {
- try {
- return lookup(key);
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new IOException("Looking up " + key + ": " + e, e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveComponentsRefresher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveComponentsRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveComponentsRefresher.java
deleted file mode 100644
index b6627a7..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveComponentsRefresher.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import org.apache.slider.api.types.ComponentInformation;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-
-import java.util.Map;
-
-public class LiveComponentsRefresher
- implements ResourceRefresher<Map<String, ComponentInformation>> {
-
- private final StateAccessForProviders state;
-
- public LiveComponentsRefresher(StateAccessForProviders state) {
- this.state = state;
- }
-
- @Override
- public Map<String, ComponentInformation> refresh() {
- return state.getComponentInfoSnapshot();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveContainersRefresher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveContainersRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveContainersRefresher.java
deleted file mode 100644
index 68bd8a2..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveContainersRefresher.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import org.apache.slider.api.types.ContainerInformation;
-import org.apache.slider.server.appmaster.state.RoleInstance;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Refresh the container list.
- */
-public class LiveContainersRefresher implements ResourceRefresher<Map<String, ContainerInformation>> {
-
- private final StateAccessForProviders state;
-
- public LiveContainersRefresher(StateAccessForProviders state) {
- this.state = state;
- }
-
- @Override
- public Map<String, ContainerInformation> refresh() throws
- Exception {
- List<RoleInstance> containerList = state.cloneOwnedContainerList();
-
- Map<String, ContainerInformation> map = new HashMap<>();
- for (RoleInstance instance : containerList) {
- ContainerInformation serialized = instance.serialize();
- map.put(serialized.containerId, serialized);
- }
- return map;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveNodesRefresher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveNodesRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveNodesRefresher.java
deleted file mode 100644
index aeb7a11..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveNodesRefresher.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import org.apache.slider.api.types.NodeInformationList;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-
-/**
- * Update the live nodes map
- */
-public class LiveNodesRefresher
- implements ResourceRefresher<NodeInformationList> {
-
- private final StateAccessForProviders state;
-
- public LiveNodesRefresher(StateAccessForProviders state) {
- this.state = state;
- }
-
- @Override
- public NodeInformationList refresh() {
-
- return new NodeInformationList(state.getNodeInformationSnapshot().values());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveResourcesRefresher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveResourcesRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveResourcesRefresher.java
deleted file mode 100644
index f988297..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveResourcesRefresher.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import org.apache.slider.api.StatusKeys;
-import org.apache.slider.core.conf.ConfTree;
-import org.apache.slider.core.conf.ConfTreeOperations;
-import org.apache.slider.server.appmaster.state.RoleStatus;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-
-import java.util.Map;
-
-public class LiveResourcesRefresher implements ResourceRefresher<ConfTree> {
-
- private final StateAccessForProviders state;
-
- public LiveResourcesRefresher(StateAccessForProviders state) {
- this.state = state;
- }
-
- @Override
- public ConfTree refresh() throws Exception {
-
- // snapshot resources
- ConfTreeOperations resources = state.getResourcesSnapshot();
- // then add actual values
- Map<Integer, RoleStatus> roleStatusMap = state.getRoleStatusMap();
-
- for (RoleStatus status : roleStatusMap.values()) {
- String name = status.getName();
- resources.setComponentOpt(name,
- StatusKeys.COMPONENT_INSTANCES_REQUESTING,
- status.getRequested());
- resources.setComponentOpt(name,
- StatusKeys.COMPONENT_INSTANCES_ACTUAL,
- status.getActual());
- resources.setComponentOpt(name,
- StatusKeys.COMPONENT_INSTANCES_RELEASING,
- status.getReleasing());
- resources.setComponentOpt(name,
- StatusKeys.COMPONENT_INSTANCES_FAILED,
- status.getFailed());
- resources.setComponentOpt(name,
- StatusKeys.COMPONENT_INSTANCES_COMPLETED,
- status.getCompleted());
- resources.setComponentOpt(name,
- StatusKeys.COMPONENT_INSTANCES_STARTED,
- status.getStarted());
- }
- return resources.getConfTree();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveStatisticsRefresher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveStatisticsRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveStatisticsRefresher.java
deleted file mode 100644
index d31b455..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveStatisticsRefresher.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-
-import java.util.Map;
-
-public class LiveStatisticsRefresher implements ResourceRefresher<Map<String,Integer>> {
-
- private final StateAccessForProviders state;
-
- public LiveStatisticsRefresher(StateAccessForProviders state) {
- this.state = state;
- }
-
- @Override
- public Map<String, Integer> refresh() throws Exception {
-
- // snapshot resources
- return state.getLiveStatistics();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ResourceRefresher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ResourceRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ResourceRefresher.java
deleted file mode 100644
index 35f0367..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ResourceRefresher.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-/**
- * Interface which must be implemented to act as a source for cached content.
- * @param <T> type to return
- */
-public interface ResourceRefresher<T> {
- /**
- * Build an up to date version of the data
- * @return a new instance of the (JSON serializable) data
- */
- T refresh() throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ResourceSnapshotRefresher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ResourceSnapshotRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ResourceSnapshotRefresher.java
deleted file mode 100644
index c16912a..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/ResourceSnapshotRefresher.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.application.resources;
-
-import org.apache.slider.core.conf.ConfTree;
-import org.apache.slider.core.conf.ConfTreeOperations;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-
-public class ResourceSnapshotRefresher implements ResourceRefresher<ConfTree> {
-
- private final StateAccessForProviders state;
-
- public ResourceSnapshotRefresher(StateAccessForProviders state) {
- this.state = state;
- }
-
- @Override
- public ConfTree refresh() throws Exception {
-
- // snapshot resources
- ConfTreeOperations resources = state.getResourcesSnapshot();
- return resources.getConfTree();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/ManagementResource.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/ManagementResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/ManagementResource.java
deleted file mode 100644
index f27711a..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/ManagementResource.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.slider.server.appmaster.web.rest.management;
-
-import org.apache.slider.core.conf.AggregateConf;
-import org.apache.slider.server.appmaster.web.WebAppApi;
-import org.apache.slider.server.appmaster.web.rest.AbstractSliderResource;
-import org.apache.slider.server.appmaster.web.rest.RestPaths;
-import org.apache.slider.server.appmaster.web.rest.management.resources.AggregateConfResource;
-import org.apache.slider.server.appmaster.web.rest.management.resources.ConfTreeResource;
-import org.apache.slider.server.appmaster.web.rest.management.resources.ResourceFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import java.net.URI;
-import java.net.URL;
-
-/**
- *
- */
-public class ManagementResource extends AbstractSliderResource {
- protected static final Logger log =
- LoggerFactory.getLogger(ManagementResource.class);
- public static final String CONFIG = "config";
- public static final String APP_UNDER_MANAGEMENT = "/app";
-
- public ManagementResource(WebAppApi slider) {
- super(slider);
- }
-
- private void init(HttpServletResponse res) {
- res.setContentType(null);
- }
-
- @GET
- public Response getWadl (@Context HttpServletRequest request) {
- return redirectToAppWadl(request);
- }
-
- @GET
- @Path("/app")
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public AggregateConfResource getAggregateConfiguration(@Context UriInfo uriInfo,
- @Context HttpServletResponse res) {
- init(res);
- return ResourceFactory.createAggregateConfResource(getAggregateConf(),
- uriInfo.getAbsolutePathBuilder());
- }
-
- @GET
- @Path(APP_UNDER_MANAGEMENT+"/configurations/{config}")
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ConfTreeResource getConfTreeResource(@PathParam(CONFIG) String config,
- @Context UriInfo uriInfo,
- @Context HttpServletResponse res) {
- init(res);
- AggregateConfResource aggregateConf =
- ResourceFactory.createAggregateConfResource(getAggregateConf(),
- uriInfo.getBaseUriBuilder()
- .path(RestPaths.SLIDER_CONTEXT_ROOT)
- .path(RestPaths.MANAGEMENT + APP_UNDER_MANAGEMENT));
- return aggregateConf.getConfTree(config);
- }
-
- protected AggregateConf getAggregateConf() {
- return slider.getAppState().getInstanceDefinitionSnapshot();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ActionsResource.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ActionsResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ActionsResource.java
deleted file mode 100644
index 9b340fa..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ActionsResource.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.management.resources;
-
-public class ActionsResource {
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/AggregateConfResource.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/AggregateConfResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/AggregateConfResource.java
deleted file mode 100644
index 794daf9..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/AggregateConfResource.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.slider.server.appmaster.web.rest.management.resources;
-
-import org.apache.slider.core.conf.AggregateConf;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import javax.ws.rs.core.UriBuilder;
-import java.util.HashMap;
-import java.util.Map;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class AggregateConfResource {
- private String href;
- private final ConfTreeResource resources;
- private final ConfTreeResource internal;
- private final ConfTreeResource appConf;
- @JsonIgnore
- private Map<String, ConfTreeResource> confMap;
-
- public AggregateConfResource(AggregateConf conf, UriBuilder uriBuilder) {
- if (uriBuilder != null) {
- this.href = uriBuilder.build().toASCIIString();
- resources = ResourceFactory.createConfTreeResource(conf.getResources(),
- uriBuilder.clone().path("configurations").path("resources"));
- internal = ResourceFactory.createConfTreeResource(conf.getInternal(),
- uriBuilder.clone().path("configurations").path("internal"));
- appConf = ResourceFactory.createConfTreeResource(conf.getAppConf(),
- uriBuilder.clone().path("configurations").path("appConf"));
- initConfMap();
- } else {
- resources = null;
- internal = null;
- appConf = null;
- }
- }
-
- private void initConfMap() {
- confMap = new HashMap<>();
- confMap.put("internal", internal);
- confMap.put("resources", resources);
- confMap.put("appConf", appConf);
- }
-
- public AggregateConfResource() {
- this(null, null);
- }
-
- public ConfTreeResource getConfTree(String name) {
- return confMap.get(name);
- }
-
- public String getHref() {
- return href;
- }
-
- public void setHref(String href) {
- this.href = href;
- }
-
- public ConfTreeResource getResources() {
- return resources;
- }
-
- public ConfTreeResource getInternal() {
- return internal;
- }
-
- public ConfTreeResource getAppConf() {
- return appConf;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ComponentResource.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ComponentResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ComponentResource.java
deleted file mode 100644
index a44448e..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ComponentResource.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.slider.server.appmaster.web.rest.management.resources;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import javax.ws.rs.core.UriBuilder;
-import java.util.Map;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class ComponentResource {
- private final Map<String, String> props;
- private String href;
-
- public ComponentResource() {
- this(null, null, null, null);
- }
-
- public ComponentResource(String name,
- Map<String, String> props,
- UriBuilder uriBuilder,
- Map<String, Object> pathElems) {
- this.props = props;
- }
-
- public Map<String, String> getProps() {
- return props;
- }
-
- public String getHref() {
- return href;
- }
-
- public void setHref(String href) {
- this.href = href;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ConfTreeResource.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ConfTreeResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ConfTreeResource.java
deleted file mode 100644
index 407bab6..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ConfTreeResource.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.slider.server.appmaster.web.rest.management.resources;
-
-import org.apache.slider.core.conf.ConfTree;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import javax.ws.rs.core.UriBuilder;
-import java.util.Map;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class ConfTreeResource {
-
- private final String href;
- private final Map<String, Object> metadata;
- private final Map<String, String> global;
- private final Map<String, Map<String, String>> components;
-
- public ConfTreeResource() {
- this(null, null);
- }
-
- public ConfTreeResource(ConfTree confTree,
- UriBuilder uriBuilder) {
- if (uriBuilder != null && confTree != null) {
- metadata = confTree.metadata;
- global = confTree.global;
- components = confTree.components;
- this.href = uriBuilder.build().toASCIIString();
- } else {
- this.href = null;
- this.metadata = null;
- this.global = null;
- this.components = null;
- }
- }
-
- public Map<String, Object> getMetadata() {
- return metadata;
- }
-
- public Map<String, String> getGlobal() {
- return global;
- }
-
- public Map<String, Map<String, String>> getComponents() {
- return components;
- }
-
- public String getHref() {
- return href;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ResourceFactory.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ResourceFactory.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ResourceFactory.java
deleted file mode 100644
index 9876412..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/management/resources/ResourceFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.slider.server.appmaster.web.rest.management.resources;
-
-import org.apache.slider.core.conf.AggregateConf;
-import org.apache.slider.core.conf.ConfTree;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import javax.ws.rs.core.UriBuilder;
-import java.util.Map;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class ResourceFactory {
-
- public static AggregateConfResource createAggregateConfResource(AggregateConf conf,
- UriBuilder uriBuilder) {
- return new AggregateConfResource(conf, uriBuilder);
- }
-
- public static ConfTreeResource createConfTreeResource(ConfTree confTree,
- UriBuilder uriBuilder) {
- return new ConfTreeResource(confTree, uriBuilder);
- }
-
- public static ComponentResource createComponentResource(String name,
- Map<String, String> props,
- UriBuilder uriBuilder,
- Map<String, Object> pathElems) {
- return new ComponentResource(name, props, uriBuilder, pathElems);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/publisher/PublisherResource.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/publisher/PublisherResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/publisher/PublisherResource.java
deleted file mode 100644
index c727581..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/publisher/PublisherResource.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.slider.server.appmaster.web.rest.publisher;
-
-import org.apache.hadoop.yarn.webapp.NotFoundException;
-import org.apache.slider.core.registry.docstore.ConfigFormat;
-import org.apache.slider.core.registry.docstore.PublishedConfigSet;
-import org.apache.slider.core.registry.docstore.PublishedConfiguration;
-import org.apache.slider.core.registry.docstore.PublishedConfigurationOutputter;
-import org.apache.slider.core.registry.docstore.PublishedExports;
-import org.apache.slider.core.registry.docstore.PublishedExportsSet;
-import org.apache.slider.core.registry.docstore.UriMap;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-import org.apache.slider.server.appmaster.web.WebAppApi;
-import org.apache.slider.server.appmaster.web.rest.AbstractSliderResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static org.apache.slider.server.appmaster.web.rest.RestPaths.*;
-
-/**
- * This publishes configuration sets
- */
-public class PublisherResource extends AbstractSliderResource {
- protected static final Logger log =
- LoggerFactory.getLogger(PublisherResource.class);
- public static final String EXPORTS_NAME = "exports";
- public static final String EXPORTS_RESOURCES_PATH = "/" + EXPORTS_NAME;
- public static final String EXPORT_RESOURCE_PATH = EXPORTS_RESOURCES_PATH + "/{exportname}" ;
- public static final String SET_NAME =
- "{setname: " + PUBLISHED_CONFIGURATION_SET_REGEXP + "}";
- public static final String SETNAME = "setname";
- public static final String CLASSPATH = "/classpath";
- public static final String CONFIG = "config";
-
- public static final String SETNAME_PATTERN =
- "{"+ SETNAME+": " + PUBLISHED_CONFIGURATION_SET_REGEXP + "}";
- private static final String CONFIG_PATTERN =
- SETNAME_PATTERN + "/{"+ CONFIG +": " + PUBLISHED_CONFIGURATION_REGEXP + "}";
- private final StateAccessForProviders appState;
-
- public PublisherResource(WebAppApi slider) {
- super(slider);
- appState = slider.getAppState();
- }
-
- private void init(HttpServletResponse res, UriInfo uriInfo) {
- res.setContentType(null);
- log.debug(uriInfo.getRequestUri().toString());
- }
-
- /**
- * Get a named config set
- * @param setname name of the config set
- * @return the config set
- * @throws NotFoundException if there was no matching set
- */
- private PublishedConfigSet getConfigSet(String setname) {
- PublishedConfigSet configSet =
- appState.getPublishedConfigSet(setname);
- if (configSet == null) {
- throw new NotFoundException("Not found: " + setname);
- }
- return configSet;
- }
-
- @GET
- @Path("/")
- @Produces({MediaType.APPLICATION_JSON})
- public UriMap enumConfigSets(
- @Context UriInfo uriInfo,
- @Context HttpServletResponse res) {
- init(res, uriInfo);
- String baseURL = uriInfo.getRequestUri().toString();
- if (!baseURL.endsWith("/")) {
- baseURL += "/";
- }
- UriMap uriMap = new UriMap();
- for (String name : appState.listConfigSets()) {
- uriMap.put(name, baseURL + name);
- log.info("registering config set {} at {}", name, baseURL);
- }
- uriMap.put(EXPORTS_NAME, baseURL + EXPORTS_NAME);
- return uriMap;
- }
-
- @GET
- @Path(CLASSPATH)
- @Produces({MediaType.APPLICATION_JSON})
- public Set<URL> getAMClassPath() {
- URL[] urls = ((URLClassLoader) getClass().getClassLoader()).getURLs();
- return new LinkedHashSet<URL>(Arrays.asList(urls));
- }
-
- @GET
- @Path(EXPORTS_RESOURCES_PATH)
- @Produces({MediaType.APPLICATION_JSON})
- public PublishedExportsSet gePublishedExports() {
-
- return appState.getPublishedExportsSet();
- }
-
- @GET
- @Path(EXPORT_RESOURCE_PATH)
- @Produces({MediaType.APPLICATION_JSON})
- public PublishedExports getAMExports2(@PathParam("exportname") String exportname,
- @Context UriInfo uriInfo,
- @Context HttpServletResponse res) {
- init(res, uriInfo);
- PublishedExportsSet set = appState.getPublishedExportsSet();
- return set.get(exportname);
- }
-
- @GET
- @Path("/"+ SETNAME_PATTERN)
- @Produces({MediaType.APPLICATION_JSON})
- public PublishedConfigSet getPublishedConfiguration(
- @PathParam(SETNAME) String setname,
- @Context UriInfo uriInfo,
- @Context HttpServletResponse res) {
- init(res, uriInfo);
-
- logRequest(uriInfo);
- PublishedConfigSet publishedConfigSet = getConfigSet(setname);
- log.debug("Number of configurations: {}", publishedConfigSet.size());
- return publishedConfigSet.shallowCopy();
- }
-
- private void logRequest(UriInfo uriInfo) {
- log.info(uriInfo.getRequestUri().toString());
- }
-
- @GET
- @Path("/" + CONFIG_PATTERN)
- @Produces({MediaType.APPLICATION_JSON})
- public PublishedConfiguration getConfigurationInstance(
- @PathParam(SETNAME) String setname,
- @PathParam(CONFIG) String config,
- @Context UriInfo uriInfo,
- @Context HttpServletResponse res) {
- init(res, uriInfo);
-
- PublishedConfiguration publishedConfig =
- getPublishedConfiguration(setname, config);
- if (publishedConfig == null) {
- log.info("Configuration {} not found", config);
- throw new NotFoundException("Not found: " + uriInfo.getAbsolutePath());
- }
- return publishedConfig;
- }
-
- /**
- * Get a configuration
- * @param setname name of the config set
- * @param config config
- * @return null if there was a config, but not a set
- * @throws NotFoundException if there was no matching set
- */
- public PublishedConfiguration getPublishedConfiguration(String setname,
- String config) {
- return getConfigSet(setname).get(config);
- }
-
- @GET
- @Path("/" + CONFIG_PATTERN + ".json")
- @Produces({MediaType.APPLICATION_JSON})
- public String getConfigurationContentJson(
- @PathParam(SETNAME) String setname,
-
- @PathParam(CONFIG) String config,
- @Context UriInfo uriInfo,
- @Context HttpServletResponse res) throws IOException {
- return getStringRepresentation(setname, config, uriInfo, res,
- ConfigFormat.JSON);
- }
-
- @GET
- @Path("/" + CONFIG_PATTERN + ".xml")
- @Produces({MediaType.APPLICATION_XML})
- public String getConfigurationContentXML(
- @PathParam(SETNAME) String setname,
- @PathParam(CONFIG) String config,
- @Context UriInfo uriInfo,
- @Context HttpServletResponse res) throws IOException {
- return getStringRepresentation(setname, config, uriInfo, res,
- ConfigFormat.XML);
- }
-
- @GET
- @Path("/" + CONFIG_PATTERN + ".properties")
- @Produces({MediaType.APPLICATION_XML})
- public String getConfigurationContentProperties(
- @PathParam(SETNAME) String setname,
-
- @PathParam(CONFIG) String config,
- @Context UriInfo uriInfo,
- @Context HttpServletResponse res) throws IOException {
-
- return getStringRepresentation(setname, config, uriInfo, res,
- ConfigFormat.PROPERTIES);
- }
-
- public String getStringRepresentation(String setname,
- String config,
- UriInfo uriInfo,
- HttpServletResponse res, ConfigFormat format) throws IOException {
- // delegate (including init)
- PublishedConfiguration publishedConfig =
- getConfigurationInstance(setname, config, uriInfo, res);
- PublishedConfigurationOutputter outputter =
- publishedConfig.createOutputter(format);
- return outputter.asString();
- }
-
- @GET
- @Path("/" + CONFIG_PATTERN +"/{propertyName}")
- @Produces({MediaType.APPLICATION_JSON})
- public Map<String,String> getConfigurationProperty(
- @PathParam(SETNAME) String setname,
- @PathParam(CONFIG) String config,
- @PathParam("propertyName") String propertyName,
- @Context UriInfo uriInfo,
- @Context HttpServletResponse res) {
- PublishedConfiguration publishedConfig =
- getConfigurationInstance(setname, config, uriInfo, res);
- String propVal = publishedConfig.entries.get(propertyName);
- if (propVal == null) {
- log.debug("Configuration property {} not found in configuration {}",
- propertyName, config);
- throw new NotFoundException("Property not found: " + propertyName);
- }
- Map<String, String> rtnVal = new HashMap<>();
- rtnVal.put(propertyName, propVal);
-
- return rtnVal;
- }
-
-}