fluo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] keith-turner closed pull request #1035: Fluo 1000
Date Tue, 05 Jun 2018 20:42:06 GMT
keith-turner closed pull request #1035: Fluo 1000
URL: https://github.com/apache/fluo/pull/1035
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
index 0c7ddf07..bb3b9a65 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
@@ -4,9 +4,9 @@
  * 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
@@ -63,7 +63,7 @@
  * Oracle server is the responsible for providing incrementing logical timestamps to clients.
It
  * should never give the same timestamp to two clients and it should always provide an incrementing
  * timestamp.
- * 
+ *
  * <p>
  * If multiple oracle servers are run, they will choose a leader and clients will automatically
  * connect to that leader. If the leader goes down, the client will automatically fail over
to the
@@ -195,6 +195,11 @@ public OracleServer(Environment env) throws Exception {
 
   private void allocateTimestamp() throws Exception {
     Stat stat = new Stat();
+
+    while (curatorFramework.getState().equals(CuratorFrameworkState.LATENT)) {
+      Thread.sleep(100);
+    }
+
     byte[] d = curatorFramework.getData().storingStatIn(stat).forPath(maxTsPath);
 
     // TODO check that d is expected
@@ -208,6 +213,7 @@ private void allocateTimestamp() throws Exception {
         LongUtil.toByteArray(newMax));
     maxTs = newMax;
 
+
     if (!isLeader) {
       throw new IllegalStateException();
     }
@@ -319,7 +325,7 @@ public synchronized void start() throws Exception {
     curatorFramework.start();
 
     while (!cnxnListener.isConnected()) {
-      Thread.sleep(200);
+      Thread.sleep(100);
     }
 
     leaderSelector = new LeaderSelector(curatorFramework, ZookeeperPath.ORACLE_SERVER, this);
@@ -412,17 +418,23 @@ public void takeLeadership(CuratorFramework curatorFramework) throws
Exception {
       synchronized (this) {
         byte[] d = curatorFramework.getData().forPath(maxTsPath);
         currentTs = maxTs = LongUtil.fromByteArray(d);
+
+        isLeader = true;
       }
 
       gcTsTracker = new GcTimestampTracker();
       gcTsTracker.start();
 
-      isLeader = true;
-
       while (started) {
         // if leadership is lost, then curator will interrupt the thread that called this
method
         Thread.sleep(100);
       }
+    } catch (IllegalStateException e) {
+      if (curatorFramework.getState() == CuratorFrameworkState.STOPPED && !started)
{
+        log.debug("Saw error likely caused by stopping Oracle", e);
+      } else {
+        throw e;
+      }
     } finally {
       isLeader = false;
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message