You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/10/09 00:53:15 UTC
[26/50] [abbrv] git commit: SLIDER-149 purged all references/uses of
the curator service discovery and the original slider registry code.
SLIDER-149 purged all references/uses of the curator service discovery and the original slider registry code.
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/2154c753
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/2154c753
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/2154c753
Branch: refs/heads/develop
Commit: 2154c753023fb9f3372945277f5a63905a5b0c6d
Parents: da814b7
Author: Steve Loughran <st...@apache.org>
Authored: Thu Sep 25 21:15:36 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Thu Sep 25 21:15:36 2014 +0100
----------------------------------------------------------------------
.../funtest/accumulo/AccumuloBasicIT.groovy | 3 +-
slider-core/pom.xml | 10 -
.../org/apache/slider/client/SliderClient.java | 22 --
.../slider/core/registry/info/RegistryView.java | 42 ---
.../core/registry/info/ServiceInstanceData.java | 140 ---------
.../slideram/SliderAMClientProvider.java | 6 -
.../server/appmaster/web/SliderAMWebApp.java | 8 -
.../server/services/curator/CuratorHelper.java | 133 --------
.../server/services/curator/CuratorService.java | 115 -------
.../curator/CuratorServiceInstance.java | 78 -----
.../curator/CuratorServiceInstances.java | 42 ---
.../server/services/curator/CuratorUriSpec.java | 58 ----
.../services/curator/RegistryBinderService.java | 315 -------------------
.../registry/RegistryDiscoveryContext.java | 37 ---
.../registry/RegistryRestResources.java | 179 -----------
.../registry/RegistryServiceConstants.java | 27 --
.../registry/SliderRegistryService.java | 95 ------
.../YarnRegistryViewForProviders.java | 30 +-
.../standalone/TestStandaloneAgentAM.groovy | 4 -
.../apache/slider/test/SliderTestUtils.groovy | 5 -
.../slider/providers/hbase/HBaseKeys.java | 2 +-
.../providers/hbase/HBaseProviderService.java | 33 +-
22 files changed, 47 insertions(+), 1337 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/app-packages/accumulo/src/test/groovy/org/apache/slider/funtest/accumulo/AccumuloBasicIT.groovy
----------------------------------------------------------------------
diff --git a/app-packages/accumulo/src/test/groovy/org/apache/slider/funtest/accumulo/AccumuloBasicIT.groovy b/app-packages/accumulo/src/test/groovy/org/apache/slider/funtest/accumulo/AccumuloBasicIT.groovy
index 613769e..5d4468c 100644
--- a/app-packages/accumulo/src/test/groovy/org/apache/slider/funtest/accumulo/AccumuloBasicIT.groovy
+++ b/app-packages/accumulo/src/test/groovy/org/apache/slider/funtest/accumulo/AccumuloBasicIT.groovy
@@ -34,10 +34,9 @@ import org.apache.slider.common.tools.SliderUtils
import org.apache.slider.core.conf.ConfTree
import org.apache.slider.core.persist.ConfTreeSerDeser
import org.apache.slider.core.registry.docstore.PublishedConfiguration
-import org.apache.slider.core.registry.info.ServiceInstanceData
import org.apache.slider.core.registry.retrieve.RegistryRetriever
import org.apache.slider.funtest.framework.SliderShell
-import org.apache.slider.server.services.curator.CuratorServiceInstance
+
import org.junit.Before
import org.junit.Test
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/pom.xml
----------------------------------------------------------------------
diff --git a/slider-core/pom.xml b/slider-core/pom.xml
index 8263199..d570606 100644
--- a/slider-core/pom.xml
+++ b/slider-core/pom.xml
@@ -346,16 +346,6 @@
</dependency>
<dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-x-discovery</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-x-discovery-server</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
index de27dcd..63bf9c2 100644
--- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
@@ -109,8 +109,6 @@ 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.info.RegisteredEndpoint;
-import org.apache.slider.core.registry.info.ServiceInstanceData;
import org.apache.slider.core.registry.retrieve.RegistryRetriever;
import org.apache.slider.core.zk.BlockingZKWatcher;
import org.apache.slider.core.zk.ZKIntegration;
@@ -2472,26 +2470,6 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe
}
}
- private void logInstance(ServiceInstanceData instance,
- boolean verbose) {
- if (!verbose) {
- log.info("{}", instance.id);
- } else {
- log.info("{}: ", instance.id);
- logEndpoints(instance);
- }
- }
-
- private void logEndpoints(ServiceInstanceData instance) {
- Map<String, RegisteredEndpoint> endpoints =
- instance.listEndpoints(true);
- for (Map.Entry<String, RegisteredEndpoint> entry : endpoints.entrySet()) {
- String name = entry.getKey();
- RegisteredEndpoint endpoint = entry.getValue();
- log.info(" {}", endpoint);
- }
- }
-
/**
* list configs available for an instance
*
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/core/registry/info/RegistryView.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/registry/info/RegistryView.java b/slider-core/src/main/java/org/apache/slider/core/registry/info/RegistryView.java
deleted file mode 100644
index 89b9c6e..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/registry/info/RegistryView.java
+++ /dev/null
@@ -1,42 +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.core.registry.info;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@Deprecated
-public class RegistryView {
-
- /**
- * Endpoints
- */
- public Map<String, RegisteredEndpoint> endpoints =
- new HashMap<String, RegisteredEndpoint>(2);
-
- public String configurationsURL;
-
- public String documentsURL;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/core/registry/info/ServiceInstanceData.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/registry/info/ServiceInstanceData.java b/slider-core/src/main/java/org/apache/slider/core/registry/info/ServiceInstanceData.java
deleted file mode 100644
index 52ae2e2..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/registry/info/ServiceInstanceData.java
+++ /dev/null
@@ -1,140 +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.core.registry.info;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Service instance data to serialize with JSON.
- *
- * The equality and hash codes are derived from the
- * service type and ID, which aren't final so that JSON marshalling
- * works. Do not change these fields if an instance is stored
- * in a map
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@Deprecated
-public class ServiceInstanceData implements Serializable {
-
- public String serviceType;
- public String id;
- public String description;
- public String yarnApplicationId;
- public long registrationTimeUTC;
-
- /**
- * Anything can go into the internal view, it's specific
- * to the provider
- */
- public RegistryView internalView = new RegistryView();
-
- /**
- * External view of the service: public information
- */
- public RegistryView externalView = new RegistryView();
-
- public ServiceInstanceData() {
- }
-
- public ServiceInstanceData(String id, String serviceType) {
- this.serviceType = serviceType;
- this.id = id;
- }
-
- /**
- * Instances are equal if they look after the same service type
- * and name
- * @param o other
- * @return true if id and type match
- */
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- ServiceInstanceData that = (ServiceInstanceData) o;
-
- if (!id.equals(that.id)) {
- return false;
- }
- if (!serviceType.equals(that.serviceType)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = serviceType.hashCode();
- result = 31 * result + id.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("ServiceInstanceData{");
- sb.append("id='").append(id).append('\'');
- sb.append(", serviceType='").append(serviceType).append('\'');
- sb.append('}');
- return sb.toString();
- }
-
- /**
- * get the internal or external registry
- * @param external flag to indicate the external endpoints
- * @return a view -which may be null
- */
- public RegistryView getRegistryView(boolean external) {
- return external ? externalView : internalView;
- }
-
- /**
- * List the internal or external endpoints. This returns
- * an empty list if there are none registered
- * @param external flag to indicate the external endpoints
- * @return a map of published endpoints
- */
- public Map<String, RegisteredEndpoint> listEndpoints(boolean external) {
- RegistryView view = getRegistryView(external);
- if (view == null) {
- return new HashMap<String, RegisteredEndpoint>(0);
- }
- Map<String, RegisteredEndpoint> endpoints = view.endpoints;
- if (endpoints != null) {
- return endpoints;
- } else {
- return new HashMap<String, RegisteredEndpoint>(0);
- }
- }
-
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/providers/slideram/SliderAMClientProvider.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/providers/slideram/SliderAMClientProvider.java b/slider-core/src/main/java/org/apache/slider/providers/slideram/SliderAMClientProvider.java
index dc84f02..68562e4 100644
--- a/slider-core/src/main/java/org/apache/slider/providers/slideram/SliderAMClientProvider.java
+++ b/slider-core/src/main/java/org/apache/slider/providers/slideram/SliderAMClientProvider.java
@@ -23,8 +23,6 @@ import com.codahale.metrics.MetricRegistry;
import com.google.gson.GsonBuilder;
import org.apache.curator.CuratorZookeeperClient;
import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.x.discovery.ServiceInstance;
-import org.apache.curator.x.discovery.server.entity.ServiceNames;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.yarn.api.records.LocalResource;
@@ -165,8 +163,6 @@ public class SliderAMClientProvider extends AbstractClientProvider
CuratorFramework.class,
CuratorZookeeperClient.class,
- ServiceInstance.class,
- ServiceNames.class,
MetricRegistry.class
};
String[] jars =
@@ -177,8 +173,6 @@ public class SliderAMClientProvider extends AbstractClientProvider
"curator-framework.jar",
"curator-client.jar",
- "curator-x-discovery.jar",
- "curator-x-discovery-service.jar",
"metrics-core.jar"
};
ProviderUtils.addDependencyJars(providerResources, fileSystem, tempPath,
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
index 64be603..34080d6 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
@@ -21,21 +21,13 @@ import com.sun.jersey.api.container.filter.GZIPContentEncodingFilter;
import com.sun.jersey.api.core.ResourceConfig;
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
import com.sun.jersey.spi.container.servlet.ServletContainer;
-import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.hadoop.yarn.registry.client.api.RegistryOperations;
-import org.apache.hadoop.yarn.registry.client.services.RegistryOperationsService;
import org.apache.hadoop.yarn.webapp.Dispatcher;
import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
import org.apache.hadoop.yarn.webapp.WebApp;
-import org.apache.slider.core.registry.info.ServiceInstanceData;
import org.apache.slider.server.appmaster.web.rest.AMWadlGeneratorConfig;
import org.apache.slider.server.appmaster.web.rest.AMWebServices;
import org.apache.slider.server.appmaster.web.rest.SliderJacksonJaxbJsonProvider;
-import org.apache.slider.server.appmaster.web.rest.registry.RegistryResource;
-import org.apache.slider.server.services.curator.CuratorHelper;
-import org.apache.slider.server.services.registry.RegistryDiscoveryContext;
-import org.apache.slider.server.services.registry.RegistryRestResources;
-import org.apache.slider.server.services.registry.SliderRegistryService;
import java.util.HashMap;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorHelper.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorHelper.java b/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorHelper.java
deleted file mode 100644
index 96d296d..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorHelper.java
+++ /dev/null
@@ -1,133 +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.services.curator;
-
-import com.google.common.base.Preconditions;
-import org.apache.curator.RetryPolicy;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.retry.ExponentialBackoffRetry;
-import org.apache.curator.x.discovery.ServiceDiscovery;
-import org.apache.curator.x.discovery.ServiceDiscoveryBuilder;
-import org.apache.curator.x.discovery.strategies.RandomStrategy;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.conf.Configured;
-import org.apache.slider.core.registry.info.ServiceInstanceData;
-import org.apache.slider.server.services.registry.RegistryServiceConstants;
-import org.apache.slider.server.services.registry.RegistryDiscoveryContext;
-import org.apache.slider.server.services.registry.SliderRegistryService;
-
-/**
- * This class creates a curator -but does not start or close it. That
- * is the responsbility of the owner
- */
-@Deprecated
-public class CuratorHelper extends Configured {
-
- private final CuratorFramework curator;
- private final String connectionString;
-
- public CuratorHelper(Configuration conf, String connectionString) {
- super(conf);
- this.connectionString = connectionString;
- curator = createCurator(this.connectionString);
- }
-
-
- public CuratorFramework getCurator() {
- return curator;
- }
-
- public String getConnectionString() {
- return connectionString;
- }
-
- /**
- * Create a retry policy for this configuration
- * @param conf
- * @return
- */
- public RetryPolicy createRetryPolicy() {
- RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
- return retryPolicy;
- }
-
- private CuratorFramework createCurator(String connectionString) {
- CuratorFramework curator =
- CuratorFrameworkFactory.newClient(connectionString,
- createRetryPolicy());
- return curator;
- }
-
- /**
- * Create a discovery builder bonded to this curator
- * @return
- */
- public ServiceDiscoveryBuilder<ServiceInstanceData> createDiscoveryBuilder() {
- ServiceDiscoveryBuilder<ServiceInstanceData> discoveryBuilder =
- ServiceDiscoveryBuilder.builder(ServiceInstanceData.class);
- discoveryBuilder.client(curator);
- return discoveryBuilder;
- }
-
- /**
- * Create an instance
- * @param discoveryBuilder builder to create the discovery from
- */
-
- public SliderRegistryService createRegistryBinderService(
- String basePath,
- ServiceDiscoveryBuilder<ServiceInstanceData> discoveryBuilder) {
- discoveryBuilder.basePath(basePath);
- return new SliderRegistryService(curator,
- basePath,
- discoveryBuilder.build());
- }
-
-
- /**
- * Create an instance -including the initial binder
- * @param basePath base path
- * @return the binder service
- */
- public SliderRegistryService createRegistryBinderService(
- String basePath) {
- ServiceDiscoveryBuilder<ServiceInstanceData> discoveryBuilder =
- createDiscoveryBuilder();
- //registry will start curator as well as the binder, in the correct order
- SliderRegistryService registryBinderService =
- createRegistryBinderService(basePath, discoveryBuilder);
- return registryBinderService;
- }
-
- public RegistryDiscoveryContext createDiscoveryContext(
- ServiceDiscovery<ServiceInstanceData> discovery) {
- Preconditions.checkNotNull(discovery);
- return new RegistryDiscoveryContext(discovery,
- new RandomStrategy<ServiceInstanceData>(),
- RegistryServiceConstants.INSTANCE_REFRESH_MS,
- ServiceInstanceData.class);
-
- }
-
- @Override
- public String toString() {
- return "Curator binding " + connectionString;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorService.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorService.java b/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorService.java
deleted file mode 100644
index a98a192..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorService.java
+++ /dev/null
@@ -1,115 +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.services.curator;
-
-import com.google.common.base.Preconditions;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.utils.ZKPaths;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.IOUtils;
-import org.apache.hadoop.service.AbstractService;
-import org.apache.hadoop.yarn.registry.client.binding.ZKPathDumper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Closeable;
-
-@Deprecated
-public class CuratorService extends AbstractService {
- private static final Logger log =
- LoggerFactory.getLogger(CuratorService.class);
- protected final String basePath;
-
- private final CuratorFramework curator;
- private CuratorHelper curatorHelper;
-
-
- public CuratorService(String name,
- CuratorFramework curator,
- String basePath) {
- super(name);
- this.curator = Preconditions.checkNotNull(curator, "null curator");
- this.basePath = basePath;
- }
-
-
- @Override
- protected void serviceInit(Configuration conf) throws Exception {
- super.serviceInit(conf);
- curatorHelper = new CuratorHelper(conf, basePath);
- }
-
- @Override
- protected void serviceStart() throws Exception {
- curator.start();
- super.serviceStart();
- }
-
- @Override
- protected void serviceStop() throws Exception {
- super.serviceStop();
- closeCuratorComponent(curator);
- }
-
- public final CuratorFramework getCurator() {
- return curator;
- }
-
- protected final void closeCuratorComponent(Closeable closeable) {
- try {
- IOUtils.closeStream(closeable);
- } catch (Throwable ignored) {
- //triggered on an attempt to close before started
- log.debug("Error when closing {}", ignored);
- }
- }
-
- public final String pathForServicetype(String servicetype) {
- return ZKPaths.makePath(getBasePath(), servicetype);
- }
-
- protected final String pathForInstance(String servicetype, String id) {
- Preconditions.checkNotNull(servicetype);
- Preconditions.checkNotNull(id);
- return ZKPaths.makePath(pathForServicetype(servicetype), id);
- }
-
- public final String getBasePath() {
- return basePath;
- }
-
- public final CuratorHelper getCuratorHelper() {
- return curatorHelper;
- }
-
- @Override
- public String toString() {
- return super.toString() + "; "
- + (curatorHelper != null ? curatorHelper : "( unbound)")
- + "; " + basePath;
- }
-
- /**
- * Get an on-demand path jumper
- * @return a class that can dump the contents of the registry
- */
- public ZKPathDumper dumpPath(boolean verbose) {
- return new ZKPathDumper(curator, basePath);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorServiceInstance.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorServiceInstance.java b/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorServiceInstance.java
deleted file mode 100644
index 0acadb2..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorServiceInstance.java
+++ /dev/null
@@ -1,78 +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.services.curator;
-
-import org.apache.curator.x.discovery.ServiceInstance;
-import org.apache.curator.x.discovery.ServiceType;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonTypeInfo;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Deprecated
-public class CuratorServiceInstance<T> {
-
- public String name;
- public String id;
- public String address;
- public Integer port;
- public Integer sslPort;
- public T payload;
- public long registrationTimeUTC;
- public ServiceType serviceType;
- public CuratorUriSpec uriSpec;
-
- public CuratorServiceInstance() {
- }
-
- public CuratorServiceInstance(ServiceInstance<T> si) {
- this.name = si.getName();
- this.id = si.getId();
- this.address = si.getAddress();
- this.port = si.getPort();
- this.sslPort = si.getSslPort();
- this.payload = si.getPayload();
- this.registrationTimeUTC = si.getRegistrationTimeUTC();
- this.serviceType = si.getServiceType();
- this.uriSpec = new CuratorUriSpec();
- this.uriSpec.addAll(si.getUriSpec().getParts());
- }
-
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("CuratorServiceInstance{");
- sb.append("name='").append(name).append('\'');
- sb.append(", id='").append(id).append('\'');
- sb.append(", address='").append(address).append('\'');
- sb.append(", port=").append(port);
- sb.append(", sslPort=").append(sslPort);
- sb.append(", payload=").append(payload);
- sb.append(", registrationTimeUTC=").append(registrationTimeUTC);
- sb.append(", serviceType=").append(serviceType);
- sb.append(", uriSpec=").append(uriSpec);
- sb.append('}');
- return sb.toString();
- }
-
- @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
- public T getPayload() {
- return payload;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorServiceInstances.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorServiceInstances.java b/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorServiceInstances.java
deleted file mode 100644
index 2b575be..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorServiceInstances.java
+++ /dev/null
@@ -1,42 +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.services.curator;
-
-import com.google.common.collect.Lists;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- *
- */
-@Deprecated
-public class CuratorServiceInstances<T> {
- private final List<CuratorServiceInstance<T>> services;
-
- public CuratorServiceInstances() {
- services = Lists.newArrayList();
- }
-
- public CuratorServiceInstances(Collection<? extends CuratorServiceInstance<T>> c) {
- services = Lists.newArrayList(c);
- }
-
- public List<CuratorServiceInstance<T>> getServices() {
- return Lists.newArrayList(services);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorUriSpec.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorUriSpec.java b/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorUriSpec.java
deleted file mode 100644
index 478d3f4..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/curator/CuratorUriSpec.java
+++ /dev/null
@@ -1,58 +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.services.curator;
-
-import com.google.common.collect.Lists;
-import org.apache.curator.x.discovery.UriSpec;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-
-import java.util.List;
-
-/**
- *
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Deprecated
-public class CuratorUriSpec extends UriSpec{
-
- private final List<Part> parts = Lists.newArrayList();
-
- public CuratorUriSpec() {
- super();
- }
-
- @Override
- public List<Part> getParts() {
- return Lists.newArrayList(parts);
- }
-
- @Override
- public void add(Part part) {
- super.add(part);
- parts.add(part);
- }
-
- public void addAll(List<Part> parts) {
- parts.addAll(parts);
- }
-
- @Override
- public void remove(Part part) {
- super.remove(part);
- parts.remove(part);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/curator/RegistryBinderService.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/curator/RegistryBinderService.java b/slider-core/src/main/java/org/apache/slider/server/services/curator/RegistryBinderService.java
deleted file mode 100644
index fca967b..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/curator/RegistryBinderService.java
+++ /dev/null
@@ -1,315 +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.services.curator;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import org.apache.commons.lang.StringUtils;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.x.discovery.ServiceDiscovery;
-import org.apache.curator.x.discovery.ServiceInstance;
-import org.apache.curator.x.discovery.ServiceInstanceBuilder;
-import org.apache.curator.x.discovery.ServiceType;
-import org.apache.curator.x.discovery.UriSpec;
-import org.apache.slider.core.persist.JsonSerDeser;
-import org.apache.zookeeper.KeeperException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * YARN service for Curator service discovery; the discovery instance's
- * start/close methods are tied to the lifecycle of this service
- * @param <Payload> the payload of the operation
- */
-@Deprecated
-public class RegistryBinderService<Payload> extends CuratorService {
- private static final Logger log =
- LoggerFactory.getLogger(RegistryBinderService.class);
-
- private final ServiceDiscovery<Payload> discovery;
-
- private final Map<String, ServiceInstance<Payload>> entries =
- new HashMap<String, ServiceInstance<Payload>>();
-
- private JsonSerDeser<CuratorServiceInstance> deser =
- new JsonSerDeser<CuratorServiceInstance>(CuratorServiceInstance.class);
-
- /**
- * Create an instance
- * @param curator Does not need to be started
- * @param basePath base directory
- * @param discovery discovery instance -not yet started
- */
- public RegistryBinderService(CuratorFramework curator,
- String basePath,
- ServiceDiscovery<Payload> discovery) {
- super("RegistryBinderService", curator, basePath);
-
- this.discovery =
- Preconditions.checkNotNull(discovery, "null discovery arg");
- }
-
-
- public ServiceDiscovery<Payload> getDiscovery() {
- return discovery;
- }
-
- @Override
- protected void serviceStart() throws Exception {
- super.serviceStart();
- discovery.start();
- }
-
- @Override
- protected void serviceStop() throws Exception {
- closeCuratorComponent(discovery);
- super.serviceStop();
- }
-
- /**
- * register an instance -only valid once the service is started
- * @param id ID -must be unique
- * @param name name
- * @param url URL
- * @param payload payload (may be null)
- * @return the instance
- * @throws Exception on registration problems
- */
- public ServiceInstance<Payload> register(String name,
- String id,
- URL url,
- Payload payload) throws Exception {
- Preconditions.checkNotNull(id, "null `id` arg");
- Preconditions.checkNotNull(name, "null `name` arg");
- Preconditions.checkState(isInState(STATE.STARTED), "Not started: " + this);
-
- ServiceInstanceBuilder<Payload> instanceBuilder = builder()
- .name(name)
- .id(id)
- .payload(payload)
- .serviceType(ServiceType.DYNAMIC);
- if (url != null) {
- UriSpec uriSpec = new UriSpec(url.toString());
-
- int port = url.getPort();
- if (port == 0) {
- throw new IOException("Port undefined in " + url);
- }
- instanceBuilder
- .uriSpec(uriSpec)
- .port(port);
- }
- ServiceInstance<Payload> instance = instanceBuilder.build();
- log.info("registering {}", instance.toString());
- discovery.registerService(instance);
- log.info("registration completed {}", instance.toString());
- synchronized (this) {
- entries.put(id, instance);
- }
- return instance;
- }
-
- /**
- * Create a builder. This is already pre-prepared with address, registration
- * time and a (random) UUID
- * @return a builder
- * @throws IOException IO problems, including enumerating network ports
- */
- public ServiceInstanceBuilder<Payload> builder() throws
- IOException {
- try {
- return ServiceInstance.builder();
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new IOException(e);
- }
- }
-
-
- /**
- * List all instance IDs of a service type
- * @param servicetype service type
- * @return list of matches
- * @throws Exception
- */
- public List<String> instanceIDs(String servicetype) throws Exception {
- Preconditions.checkNotNull(servicetype);
- List<String> instanceIds;
- try {
- instanceIds =
- getCurator().getChildren().forPath(pathForServicetype(servicetype));
- } catch (KeeperException.NoNodeException e) {
- instanceIds = Lists.newArrayList();
- }
- return instanceIds;
- }
-
- /**
- * List all service types registered
- * @return a list of service types
- * @throws Exception
- */
- public List<String> serviceTypes() throws Exception {
- List<String> types;
- try {
- types =
- getCurator().getChildren().forPath(getBasePath());
- } catch (KeeperException.NoNodeException e) {
- types = Lists.newArrayList();
- }
- return types;
- }
-
-
- /**
- * Return a service instance POJO
- *
- * @param servicetype name of the service
- * @param id ID of the instance
- * @return the instance or <code>null</code> if not found
- * @throws Exception errors
- */
- public CuratorServiceInstance<Payload> queryForInstance(String servicetype, String id)
- throws Exception {
- CuratorServiceInstance<Payload> instance = null;
- String path = pathForInstance(servicetype, id);
- try {
- byte[] bytes = getCurator().getData().forPath(path);
- if (bytes!=null && bytes.length>0) {
- instance = deser.fromBytes(bytes);
- }
- } catch (KeeperException.NoNodeException ignore) {
- // ignore
- }
- return instance;
- }
-
- /**
- * List all the instances
- * @param servicetype name of the service
- * @return a list of instances and their payloads
- * @throws IOException any problem
- */
- public List<CuratorServiceInstance<Payload>> listInstances(String servicetype) throws
- IOException {
- try {
- List<String> instanceIDs = instanceIDs(servicetype);
- List<CuratorServiceInstance<Payload>> instances =
- new ArrayList<CuratorServiceInstance<Payload>>(instanceIDs.size());
- for (String instanceID : instanceIDs) {
- CuratorServiceInstance<Payload> instance =
- queryForInstance(servicetype, instanceID);
- if (instance != null) {
- instances.add(instance);
- }
- }
- return instances;
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new IOException(e);
- }
- }
-
- /**
- * Find an instance with a given ID
- * @param instances instances
- * @param name ID to look for
- * @return the discovered instance or null
- */
- public CuratorServiceInstance<Payload> findByID(List<CuratorServiceInstance<Payload>> instances, String name) {
- Preconditions.checkNotNull(name);
- for (CuratorServiceInstance<Payload> instance : instances) {
- if (instance.id.equals(name)) {
- return instance;
- }
- }
- return null;
- }
-
- /**
- * Find a single instance -return that value or raise an exception
- * @param serviceType service type
- * @param name the name (required(
- * @return the instance that matches the criteria
- * @throws FileNotFoundException if there were no matches
- * @throws IOException any network problem
- */
- public CuratorServiceInstance<Payload> findInstance(String serviceType,
- String name) throws IOException {
- Preconditions.checkArgument(StringUtils.isNotEmpty(name), "name");
- return findInstances(serviceType, name).get(0);
- }
- /**
- * List registry entries. If a name was given, then the single match is returned
- * -otherwise all entries matching the service type
- * @param serviceType service type
- * @param name an optional name
- * @return the (non-empty) list of instances that match the criteria
- * @throws FileNotFoundException if there were no matches
- * @throws IOException any network problem
- */
- public List<CuratorServiceInstance<Payload>> findInstances(String serviceType,
- String name)
- throws FileNotFoundException, IOException {
- List<CuratorServiceInstance<Payload>> instances =
- listInstances(serviceType);
- if (instances.isEmpty()) {
- throw new FileNotFoundException(
- "No registry entries for service type " + serviceType);
- }
- if (StringUtils.isNotEmpty(name)) {
- CuratorServiceInstance<Payload> foundInstance = findByID(instances, name);
- if (foundInstance == null) {
- throw new FileNotFoundException(
- "No registry entries for service name " + name
- + " and service type " + serviceType);
- }
- instances.clear();
- instances.add(foundInstance);
- }
- return instances;
- }
-
- /**
- * Enum all service types in the registry
- * @return a possibly empty collection of service types
- * @throws IOException networking
- */
- public Collection<String> getServiceTypes() throws IOException {
- try {
- return getDiscovery().queryForNames();
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new IOException(e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryDiscoveryContext.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryDiscoveryContext.java b/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryDiscoveryContext.java
deleted file mode 100644
index d6b676f..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryDiscoveryContext.java
+++ /dev/null
@@ -1,37 +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.services.registry;
-
-import org.apache.curator.x.discovery.ProviderStrategy;
-import org.apache.curator.x.discovery.ServiceDiscovery;
-import org.apache.curator.x.discovery.server.contexts.GenericDiscoveryContext;
-import org.apache.slider.core.registry.info.ServiceInstanceData;
-
-@Deprecated
-public class RegistryDiscoveryContext extends GenericDiscoveryContext<ServiceInstanceData> {
-
- public RegistryDiscoveryContext(ServiceDiscovery<ServiceInstanceData> serviceDiscovery,
- ProviderStrategy<ServiceInstanceData> providerStrategy,
- int instanceRefreshMs,
- Class<ServiceInstanceData> payloadType) {
- super(serviceDiscovery, providerStrategy, instanceRefreshMs, payloadType);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryRestResources.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryRestResources.java b/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryRestResources.java
deleted file mode 100644
index ea97847..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryRestResources.java
+++ /dev/null
@@ -1,179 +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.services.registry;
-
-import com.google.inject.Singleton;
-import org.apache.curator.x.discovery.ServiceInstance;
-import org.apache.curator.x.discovery.server.rest.DiscoveryContext;
-import org.apache.curator.x.discovery.server.rest.DiscoveryResource;
-import org.apache.slider.core.registry.info.ServiceInstanceData;
-import org.apache.slider.server.appmaster.web.rest.RestPaths;
-import org.apache.slider.server.services.curator.CuratorServiceInstance;
-import org.apache.slider.server.services.curator.CuratorServiceInstances;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-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 javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-import java.util.Random;
-
-@Singleton
-@Path(RestPaths.SLIDER_PATH_REGISTRY)
-@Deprecated
-public class RegistryRestResources extends DiscoveryResource<ServiceInstanceData> {
- public static final String SERVICE_NAME = RestPaths.REGISTRY_SERVICE +"/{name}";
- public static final String SERVICE_NAME_ID = SERVICE_NAME + "/{id}";
- protected static final Logger log =
- LoggerFactory.getLogger(RegistryRestResources.class);
- private final SliderRegistryService registry;
- private DiscoveryContext<ServiceInstanceData> context;
- private Random randomizer = new Random();
-
- public RegistryRestResources(@Context DiscoveryContext<ServiceInstanceData> context,
- SliderRegistryService registry) {
- super(context);
- this.context = context;
- this.registry = registry;
- }
-
-// @GET
- public Response getWadl (@Context HttpServletRequest request) {
- try {
- URI location = new URL(request.getScheme(),
- request.getServerName(),
- request.getServerPort(),
- "/application.wadl").toURI();
- return Response.temporaryRedirect(location).build();
- } catch (Exception e) {
- log.error("Error during redirect to WADL", e);
- throw new WebApplicationException(Response.serverError().build());
- }
- }
-
- @javax.ws.rs.GET
- @javax.ws.rs.Produces({MediaType.APPLICATION_JSON})
- public Response getAtRoot() {
- try {
- List<String>
- instances = registry.serviceTypes();
- return Response.ok(instances).build();
- } catch (Exception e) {
- log.error("Error during generation of response", e);
- return Response.serverError().build();
- }
- }
-
-
- @Override
- @javax.ws.rs.GET
- @javax.ws.rs.Path(SERVICE_NAME)
- @javax.ws.rs.Produces({MediaType.APPLICATION_JSON})
- public Response getAll(@PathParam("name") String name) {
- try {
- List<CuratorServiceInstance<ServiceInstanceData>>
- instances = registry.listInstances(name);
- return Response.ok(
- new CuratorServiceInstances<ServiceInstanceData>(instances)).build();
- } catch (Exception e) {
- log.error("Error during generation of response", e);
- return Response.serverError().build();
- }
- }
-
- @Override
- @GET
- @Path(SERVICE_NAME_ID)
- @Produces(MediaType.APPLICATION_JSON)
- public Response get(@PathParam("name") String name,
- @PathParam("id") String id) {
- try {
- CuratorServiceInstance<ServiceInstanceData> instance = registry.queryForInstance(name, id);
- if ( instance == null )
- {
- return Response.status(Response.Status.NOT_FOUND).build();
- }
- Response.ResponseBuilder builder = Response.ok(instance);
- return builder.build();
- } catch (Exception e) {
- log.error("Trying to get instance {} from service {}: {})",
- id,
- name,
- e);
- return Response.serverError().build();
- }
- }
-
- @Override
- @GET
- @Path("v1/anyservice/{name}")
- @Produces(MediaType.APPLICATION_JSON)
- public Response getAny(@PathParam("name") String name) {
- try {
- List<CuratorServiceInstance<ServiceInstanceData>>
- instances = registry.listInstances(name);
- if (instances == null || instances.isEmpty()) {
- return Response.status(Response.Status.NOT_FOUND).build();
- }
-
- CuratorServiceInstance<ServiceInstanceData> randomInstance =
- instances.get(randomizer.nextInt(instances.size()));
- if ( randomInstance == null )
- {
- return Response.status(Response.Status.NOT_FOUND).build();
- }
- return Response.ok(randomInstance).build();
- } catch (Exception e) {
- log.error(String.format("Trying to get any instance from service (%s)", name), e);
- return Response.serverError().build();
- }
- }
-
- @Override
- @PUT
- @Path(SERVICE_NAME_ID)
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response putService(ServiceInstance<ServiceInstanceData> instance,
- @PathParam("name") String name,
- @PathParam("id") String id) {
- throw new UnsupportedOperationException("putService not supported");
- }
-
- @Override
- @DELETE
- @Path(SERVICE_NAME_ID)
- public Response removeService(@PathParam("name") String name,
- @PathParam("id") String id) {
- throw new UnsupportedOperationException("removeService not supported");
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryServiceConstants.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryServiceConstants.java b/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryServiceConstants.java
deleted file mode 100644
index f3a107f..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/registry/RegistryServiceConstants.java
+++ /dev/null
@@ -1,27 +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.services.registry;
-
-/**
- * These constants are unique to the slider registry service itself
- */
-@Deprecated
-public class RegistryServiceConstants {
- public static final int INSTANCE_REFRESH_MS = 1000;
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/registry/SliderRegistryService.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/registry/SliderRegistryService.java b/slider-core/src/main/java/org/apache/slider/server/services/registry/SliderRegistryService.java
deleted file mode 100644
index ab92c82..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/registry/SliderRegistryService.java
+++ /dev/null
@@ -1,95 +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.services.registry;
-
-import com.google.common.base.Preconditions;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.x.discovery.ServiceDiscovery;
-import org.apache.slider.core.registry.info.ServiceInstanceData;
-import org.apache.slider.server.services.curator.CuratorServiceInstance;
-import org.apache.slider.server.services.curator.RegistryBinderService;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This is the registry service, which tries to hide exactly how the
- * registry is implemented
- */
-@Deprecated
-public class SliderRegistryService
- extends RegistryBinderService<ServiceInstanceData> {
-
- private ServiceInstanceData selfRegistration;
-
- public SliderRegistryService(CuratorFramework curator,
- String basePath,
- ServiceDiscovery<ServiceInstanceData> discovery) {
- super(curator, basePath, discovery);
- }
-
-
- public List<ServiceInstanceData> listInstancesByType(String serviceType) throws
- IOException {
- List<CuratorServiceInstance<ServiceInstanceData>> services =
- listInstances(serviceType);
- List<ServiceInstanceData> payloads = new ArrayList<ServiceInstanceData>(services.size());
- for (CuratorServiceInstance<ServiceInstanceData> instance : services) {
- payloads.add(instance.payload);
- }
- return payloads;
- }
-
- public ServiceInstanceData getSelfRegistration() {
- return selfRegistration;
- }
-
- private void setSelfRegistration(ServiceInstanceData selfRegistration) {
- this.selfRegistration = selfRegistration;
- }
-
- /**
- * register an instance -only valid once the service is started.
- * This sets the selfRegistration field
- * @param instanceData instance data
- * @param url URL to register
- * @throws IOException on registration problems
- */
- public void registerSelf(ServiceInstanceData instanceData, URL url) throws IOException {
- registerServiceInstance(instanceData, url);
- setSelfRegistration(instanceData);
- }
-
- public void registerServiceInstance(
- ServiceInstanceData instanceData, URL url) throws IOException {
- Preconditions.checkNotNull(instanceData);
- Preconditions.checkNotNull(instanceData.id);
- Preconditions.checkNotNull(instanceData.serviceType);
-
- try {
- register(instanceData.serviceType, instanceData.id, url, instanceData);
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new IOException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/main/java/org/apache/slider/server/services/yarnregistry/YarnRegistryViewForProviders.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/yarnregistry/YarnRegistryViewForProviders.java b/slider-core/src/main/java/org/apache/slider/server/services/yarnregistry/YarnRegistryViewForProviders.java
index a08cfaf..d699279 100644
--- a/slider-core/src/main/java/org/apache/slider/server/services/yarnregistry/YarnRegistryViewForProviders.java
+++ b/slider-core/src/main/java/org/apache/slider/server/services/yarnregistry/YarnRegistryViewForProviders.java
@@ -102,18 +102,17 @@ public class YarnRegistryViewForProviders {
/**
- * Add a service under
- * @param componentName
- * @param record
- * @param ephemeral
+ * Add a service under a path
+ * @param username user
+ * @param serviceClass service class to use under ~user
+ * @param serviceName name of the service
+ * @param record service record
* @throws IOException
*/
public void putService(String username,
String serviceClass,
String serviceName,
ServiceRecord record) throws IOException {
-
-
String path = RegistryOperationUtils.servicePath(
username, serviceClass, serviceName);
registryOperations.mknode(RegistryPathUtils.parentOf(path), true);
@@ -122,6 +121,25 @@ public class YarnRegistryViewForProviders {
}
+ /**
+ * Add a service under a path for the current user
+ * @param serviceClass service class to use under ~user
+ * @param serviceName name of the service
+ * @param record service record
+ * @throws IOException
+ */
+ public void putService(
+ String serviceClass,
+ String serviceName,
+ ServiceRecord record) throws IOException {
+ String path = RegistryOperationUtils.servicePath(
+ user, serviceClass, serviceName);
+ registryOperations.mknode(RegistryPathUtils.parentOf(path), true);
+ registryOperations.create(path, record, CreateFlags.OVERWRITE);
+
+ }
+
+
public void rmComponent(String componentName) throws IOException {
String path = RegistryOperationUtils.componentPath(
user, sliderServiceclass, instanceName,
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy
index e04f9cb..941ca83 100644
--- a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy
@@ -26,15 +26,11 @@ import org.apache.hadoop.yarn.api.records.YarnApplicationState
import org.apache.slider.agent.AgentMiniClusterTestBase
import org.apache.slider.api.ClusterNode
import org.apache.slider.client.SliderClient
-import org.apache.slider.common.SliderExitCodes
import org.apache.slider.common.SliderKeys
import org.apache.slider.common.params.ActionRegistryArgs
import org.apache.slider.core.exceptions.SliderException
import org.apache.slider.core.main.LauncherExitCodes
import org.apache.slider.core.main.ServiceLauncher
-import org.apache.slider.core.registry.info.ServiceInstanceData
-import org.apache.slider.server.services.curator.CuratorServiceInstance
-import org.apache.slider.server.services.registry.SliderRegistryService
import org.junit.Test
@CompileStatic
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
index 7621a4d..9f8e850 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
@@ -45,15 +45,10 @@ import org.apache.slider.core.exceptions.SliderException
import org.apache.slider.core.exceptions.WaitTimeoutException
import org.apache.slider.core.main.ServiceLaunchException
import org.apache.slider.core.main.ServiceLauncher
-import org.apache.slider.core.persist.JsonSerDeser
import org.apache.slider.core.registry.docstore.PublishedConfigSet
-import org.apache.slider.core.registry.info.ServiceInstanceData
-import org.apache.slider.server.services.curator.CuratorServiceInstance
import org.junit.Assert
import org.junit.Assume
-import java.lang.reflect.Array
-
import static Arguments.ARG_OPTION
/**
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseKeys.java
----------------------------------------------------------------------
diff --git a/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseKeys.java b/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseKeys.java
index 2a20438..064414e 100644
--- a/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseKeys.java
+++ b/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseKeys.java
@@ -88,7 +88,7 @@ public interface HBaseKeys {
/**
* Service type used in registry
*/
- String HBASE_SERVICE_TYPE = "org.apache.hbase";
+ String HBASE_SERVICE_TYPE = "org-apache-hbase";
String HBASE_SITE_PUBLISHED_CONFIG = "hbase-site";
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2154c753/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseProviderService.java
----------------------------------------------------------------------
diff --git a/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseProviderService.java b/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseProviderService.java
index 372038b..3c059d9 100644
--- a/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseProviderService.java
+++ b/slider-providers/hbase/slider-hbase-provider/src/main/java/org/apache/slider/providers/hbase/HBaseProviderService.java
@@ -18,10 +18,10 @@
package org.apache.slider.providers.hbase;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.registry.client.binding.RegistryTypeUtils;
import org.apache.hadoop.yarn.registry.client.types.ServiceRecord;
import org.apache.slider.api.InternalKeys;
import org.apache.slider.common.SliderKeys;
@@ -37,7 +37,7 @@ import org.apache.slider.core.exceptions.SliderException;
import org.apache.slider.core.exceptions.SliderInternalStateException;
import org.apache.slider.core.registry.docstore.PublishedConfigSet;
import org.apache.slider.core.registry.docstore.PublishedConfiguration;
-import org.apache.slider.core.registry.info.ServiceInstanceData;
+import org.apache.slider.core.registry.info.CustomRegistryConstants;
import org.apache.slider.providers.AbstractProviderService;
import org.apache.slider.providers.ProviderCompleted;
import org.apache.slider.providers.ProviderCore;
@@ -57,6 +57,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
@@ -253,21 +254,29 @@ public class HBaseProviderService extends AbstractProviderService
private void registerHBaseServiceEntry() throws IOException {
- String name = amState.getApplicationName() ;
-// name += ".hbase";
- ServiceInstanceData instanceData = new ServiceInstanceData(name,
- HBASE_SERVICE_TYPE);
- log.info("registering {}/{}", name, HBASE_SERVICE_TYPE );
+
+ String name = amState.getApplicationName() ;
+ ServiceRecord serviceRecord = new ServiceRecord();
+
+ try {
+ URL configURL = new URL(amWebAPI, SLIDER_PATH_PUBLISHER + "/" + HBASE_SERVICE_TYPE);
+
+ serviceRecord.addExternalEndpoint(
+ RegistryTypeUtils.restEndpoint(
+ CustomRegistryConstants.PUBLISHER_REST_API,
+ configURL.toURI()));
+ } catch (URISyntaxException e) {
+ log.warn("failed to create config URL: {}", e, e);
+ }
+ log.info("registering {}/{}", name, HBASE_SERVICE_TYPE);
+ yarnRegistry.putService(HBASE_SERVICE_TYPE, name, serviceRecord);
+
PublishedConfiguration publishedSite =
new PublishedConfiguration("HBase site", siteConf);
PublishedConfigSet configSet =
amState.getOrCreatePublishedConfigSet(HBASE_SERVICE_TYPE);
- instanceData.externalView.configurationsURL = SliderUtils.appendToURL(
- amWebAPI.toExternalForm(), SLIDER_PATH_PUBLISHER, HBASE_SERVICE_TYPE);
- configSet.put(HBASE_SITE_PUBLISHED_CONFIG, publishedSite);
- registry.registerServiceInstance(instanceData, null);
-
+ configSet.put(HBASE_SITE_PUBLISHED_CONFIG, publishedSite);
}
/**