helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject [1/2] Revert "[HELIX-257] Upgraded restlet from 1.1.10 to 2.1.4 (merged pull request from mrietveld)"
Date Sat, 12 Apr 2014 23:26:50 GMT
Repository: helix
Updated Branches:
  refs/heads/helix-0.6.2-release 5110f2592 -> dea0f5be4


http://git-wip-us.apache.org/repos/asf/helix/blob/dea0f5be/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java
b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java
index e415da9..96277cf 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java
@@ -26,7 +26,6 @@ import java.util.Timer;
 import java.util.TimerTask;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicReference;
-import java.util.logging.Level;
 
 import org.I0Itec.zkclient.DataUpdater;
 import org.apache.helix.AccessOption;
@@ -74,10 +73,6 @@ public class ZKPropertyTransferServer {
   Component _component = null;
   Timer _timer = null;
 
-  static {
-    org.restlet.engine.Engine.setLogLevel(Level.SEVERE);
-  }
-
   /**
    * Timertask for zookeeper batched writes
    */

http://git-wip-us.apache.org/repos/asf/helix/blob/dea0f5be/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java
b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java
index 33593ae..f704f54 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java
@@ -2,19 +2,19 @@ package org.apache.helix.controller.restlet;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * 
+ * 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
+ * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -29,49 +29,62 @@ import org.codehaus.jackson.type.TypeReference;
 import org.restlet.data.Form;
 import org.restlet.data.MediaType;
 import org.restlet.data.Status;
-import org.restlet.representation.Representation;
-import org.restlet.representation.Variant;
-import org.restlet.resource.ServerResource;
+import org.restlet.resource.Representation;
+import org.restlet.resource.Resource;
 
 /**
  * REST resource for ZkPropertyTransfer server to receive PUT requests
  * that submits ZNRecordUpdates
  */
-public class ZNRecordUpdateResource extends ServerResource {
-    public static final String UPDATEKEY = "ZNRecordUpdate";
-    private static Logger LOG = Logger.getLogger(ZNRecordUpdateResource.class);
+public class ZNRecordUpdateResource extends Resource {
+  public static final String UPDATEKEY = "ZNRecordUpdate";
+  private static Logger LOG = Logger.getLogger(ZNRecordUpdateResource.class);
 
-    public ZNRecordUpdateResource() { 
-        getVariants().add(new Variant(MediaType.TEXT_PLAIN));
-        getVariants().add(new Variant(MediaType.APPLICATION_JSON));
-        setNegotiated(false);
-    }
-    
-    @Override
-    public Representation put(Representation entity) {
-        try {
-            ZKPropertyTransferServer server = ZKPropertyTransferServer.getInstance();
+  @Override
+  public boolean allowGet() {
+    return false;
+  }
 
-            Form form = new Form(entity);
-            String jsonPayload = form.getFirstValue(UPDATEKEY, true);
+  @Override
+  public boolean allowPost() {
+    return false;
+  }
 
-            // Parse the map from zkPath --> ZNRecordUpdate from the payload
-            StringReader sr = new StringReader(jsonPayload);
-            ObjectMapper mapper = new ObjectMapper();
-            TypeReference<TreeMap<String, ZNRecordUpdate>> typeRef = new TypeReference<TreeMap<String,
ZNRecordUpdate>>() {
-            };
-            Map<String, ZNRecordUpdate> holderMap = mapper.readValue(sr, typeRef);
-            // Enqueue the ZNRecordUpdate for sending
-            for (ZNRecordUpdate holder : holderMap.values()) {
-                server.enqueueData(holder);
-                LOG.info("Received " + holder.getPath() + " from " + getRequest().getClientInfo().getAddress());
-            }
-            getResponse().setStatus(Status.SUCCESS_OK);
-        } catch (Exception e) {
-            LOG.error("", e);
-            getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
-        }
-        return null;
-    }
+  @Override
+  public boolean allowPut() {
+    return true;
+  }
+
+  @Override
+  public boolean allowDelete() {
+    return false;
+  }
 
+  @Override
+  public void storeRepresentation(Representation entity) {
+    try {
+      ZKPropertyTransferServer server = ZKPropertyTransferServer.getInstance();
+
+      Form form = new Form(entity);
+      String jsonPayload = form.getFirstValue(UPDATEKEY, true);
+
+      // Parse the map from zkPath --> ZNRecordUpdate from the payload
+      StringReader sr = new StringReader(jsonPayload);
+      ObjectMapper mapper = new ObjectMapper();
+      TypeReference<TreeMap<String, ZNRecordUpdate>> typeRef =
+          new TypeReference<TreeMap<String, ZNRecordUpdate>>() {
+          };
+      Map<String, ZNRecordUpdate> holderMap = mapper.readValue(sr, typeRef);
+      // Enqueue the ZNRecordUpdate for sending
+      for (ZNRecordUpdate holder : holderMap.values()) {
+        server.enqueueData(holder);
+        LOG.info("Received " + holder.getPath() + " from "
+            + getRequest().getClientInfo().getAddress());
+      }
+      getResponse().setStatus(Status.SUCCESS_OK);
+    } catch (Exception e) {
+      LOG.error("", e);
+      getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/dea0f5be/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferApplication.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferApplication.java
b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferApplication.java
index 68d35cb..f345fe2 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferApplication.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferApplication.java
@@ -22,7 +22,7 @@ package org.apache.helix.controller.restlet;
 import org.restlet.Application;
 import org.restlet.Context;
 import org.restlet.Restlet;
-import org.restlet.routing.Router;
+import org.restlet.Router;
 
 /**
  * Restlet application for ZkPropertyTransfer server
@@ -37,7 +37,7 @@ public class ZkPropertyTransferApplication extends Application {
   }
 
   @Override
-  public Restlet createInboundRoot() {
+  public Restlet createRoot() {
     Router router = new Router(getContext());
     router.attach("/" + ZKPropertyTransferServer.RESTRESOURCENAME, ZNRecordUpdateResource.class);
     return router;

http://git-wip-us.apache.org/repos/asf/helix/blob/dea0f5be/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferClient.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferClient.java
b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferClient.java
index 092d845..ed1a114 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferClient.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZkPropertyTransferClient.java
@@ -30,18 +30,17 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
-import java.util.logging.Level;
 
 import org.apache.helix.ZNRecord;
 import org.apache.log4j.Logger;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.restlet.Client;
-import org.restlet.Request;
-import org.restlet.Response;
 import org.restlet.data.MediaType;
 import org.restlet.data.Method;
 import org.restlet.data.Protocol;
 import org.restlet.data.Reference;
+import org.restlet.data.Request;
+import org.restlet.data.Response;
 import org.restlet.data.Status;
 
 public class ZkPropertyTransferClient {
@@ -62,10 +61,6 @@ public class ZkPropertyTransferClient {
   Timer _timer;
   volatile String _webServiceUrl = "";
 
-  static {
-    org.restlet.engine.Engine.setLogLevel(Level.SEVERE);
-  }
-
   public ZkPropertyTransferClient(int maxConcurrentTasks) {
     _maxConcurrentTasks = maxConcurrentTasks;
     _executorService = Executors.newFixedThreadPool(_maxConcurrentTasks);

http://git-wip-us.apache.org/repos/asf/helix/blob/dea0f5be/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordStreamingSerializer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordStreamingSerializer.java
b/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordStreamingSerializer.java
index f97774e..23de9fd 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordStreamingSerializer.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordStreamingSerializer.java
@@ -35,8 +35,8 @@ import org.codehaus.jackson.JsonFactory;
 import org.codehaus.jackson.JsonGenerator;
 import org.codehaus.jackson.JsonParser;
 import org.codehaus.jackson.JsonToken;
-import org.restlet.engine.util.Base64;
 
+import com.noelios.restlet.util.Base64;
 
 public class ZNRecordStreamingSerializer implements ZkSerializer {
   private static Logger LOG = Logger.getLogger(ZNRecordStreamingSerializer.class);

http://git-wip-us.apache.org/repos/asf/helix/blob/dea0f5be/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3f446f3..b14e164 100644
--- a/pom.xml
+++ b/pom.xml
@@ -258,9 +258,9 @@ under the License.
   <dependencyManagement>
     <dependencies>
       <dependency>
-        <groupId>org.restlet.jse</groupId>
-        <artifactId>org.restlet</artifactId>
-        <version>2.2.0</version>
+        <groupId>com.noelios.restlet</groupId>
+        <artifactId>com.noelios.restlet</artifactId>
+        <version>1.1.10</version>
       </dependency>
       <dependency>
         <groupId>org.apache.helix</groupId>


Mime
View raw message