org.apache.giraph.zk
Class ZooKeeperManager

java.lang.Object
  extended by org.apache.giraph.zk.ZooKeeperManager

public class ZooKeeperManager
extends Object

Manages the election of ZooKeeper servers, starting/stopping the services, etc.


Nested Class Summary
static class ZooKeeperManager.State
          State of the application
 
Constructor Summary
ZooKeeperManager(org.apache.hadoop.mapreduce.Mapper.Context context, ImmutableClassesGiraphConfiguration configuration)
          Constructor with context.
 
Method Summary
 boolean computationDone()
          Check if all the computation is done.
 void createCandidateStamp()
          Create a HDFS stamp for this task.
static String getBasePath(org.apache.hadoop.conf.Configuration conf)
          Return the base ZooKeeper ZNode from which all other ZNodes Giraph creates should be sited, for instance in a multi-tenant ZooKeeper, the znode reserved for Giraph
 String getZooKeeperServerPortString()
          Users can get the server port string to connect to ZooKeeper
 void logZooKeeperOutput(org.apache.log4j.Level level)
          Log the zookeeper output from the process (if it was started)
 void offlineZooKeeperServers(ZooKeeperManager.State state)
          Notify the ZooKeeper servers that this partition is done with all ZooKeeper communication.
 void onlineZooKeeperServers()
          If this task has been selected, online a ZooKeeper server.
 boolean runsZooKeeper()
          Is this task running a ZooKeeper server? Only could be true if called after onlineZooKeeperServers().
 void setup()
          Create the candidate stamps and decide on the servers to start if you are partition 0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZooKeeperManager

public ZooKeeperManager(org.apache.hadoop.mapreduce.Mapper.Context context,
                        ImmutableClassesGiraphConfiguration configuration)
                 throws IOException
Constructor with context.

Parameters:
context - Context to be stored internally
configuration - Configuration
Throws:
IOException
Method Detail

getBasePath

public static String getBasePath(org.apache.hadoop.conf.Configuration conf)
Return the base ZooKeeper ZNode from which all other ZNodes Giraph creates should be sited, for instance in a multi-tenant ZooKeeper, the znode reserved for Giraph

Parameters:
conf - Necessary to access user-provided values
Returns:
String of path without trailing slash

setup

public void setup()
           throws IOException,
                  InterruptedException
Create the candidate stamps and decide on the servers to start if you are partition 0.

Throws:
IOException
InterruptedException

createCandidateStamp

public void createCandidateStamp()
Create a HDFS stamp for this task. If another task already created it, then this one will fail, which is fine.


computationDone

public boolean computationDone()
Check if all the computation is done.

Returns:
true if all computation is done.

getZooKeeperServerPortString

public String getZooKeeperServerPortString()
Users can get the server port string to connect to ZooKeeper

Returns:
server port string - comma separated

onlineZooKeeperServers

public void onlineZooKeeperServers()
If this task has been selected, online a ZooKeeper server. Otherwise, wait until this task knows that the ZooKeeper servers have been onlined.


offlineZooKeeperServers

public void offlineZooKeeperServers(ZooKeeperManager.State state)
Notify the ZooKeeper servers that this partition is done with all ZooKeeper communication. If this task is running a ZooKeeper server, kill it when all partitions are done and wait for completion. Clean up the ZooKeeper local directory as well.

Parameters:
state - State of the application

runsZooKeeper

public boolean runsZooKeeper()
Is this task running a ZooKeeper server? Only could be true if called after onlineZooKeeperServers().

Returns:
true if running a ZooKeeper server, false otherwise

logZooKeeperOutput

public void logZooKeeperOutput(org.apache.log4j.Level level)
Log the zookeeper output from the process (if it was started)

Parameters:
level - Log level to print at


Copyright © 2011-2013 The Apache Software Foundation. All Rights Reserved.