public class org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection extends java.lang.Object implements org.apache.helix.zookeeper.zkclient.IZkDataListener, org.apache.helix.zookeeper.zkclient.IZkStateListener
{
private static final org.slf4j.Logger LOG;
private static final java.lang.String PREFIX;
private final org.apache.helix.zookeeper.api.client.HelixZkClient _zkClient;
private final java.lang.String _basePath;
private final org.apache.helix.zookeeper.datamodel.ZNRecord _participantInfo;
private org.apache.helix.zookeeper.datamodel.ZNRecord _currentLeaderInfo;
private java.lang.String _myEphemeralSequentialPath;
private volatile boolean _isLeader;
public void <init>(org.apache.helix.zookeeper.api.client.HelixZkClient, java.lang.String, org.apache.helix.zookeeper.datamodel.ZNRecord)
{
java.lang.Throwable v;
org.apache.helix.zookeeper.datamodel.serializer.ZNRecordSerializer v;
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
org.apache.helix.zookeeper.api.client.HelixZkClient v, v;
java.lang.IllegalArgumentException v, v;
org.apache.helix.zookeeper.datamodel.ZNRecord v;
java.lang.String v;
boolean v, v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
v := @parameter: org.apache.helix.zookeeper.api.client.HelixZkClient;
v := @parameter: java.lang.String;
v := @parameter: org.apache.helix.zookeeper.datamodel.ZNRecord;
specialinvoke v.<java.lang.Object: void <init>()>();
entermonitor v;
label:
if v == null goto label;
v = interfaceinvoke v.<org.apache.helix.zookeeper.api.client.HelixZkClient: boolean isClosed()>();
if v == 0 goto label;
label:
v = new java.lang.IllegalArgumentException;
specialinvoke v.<java.lang.IllegalArgumentException: void <init>(java.lang.String)>("ZkClient cannot be null or closed!");
throw v;
label:
v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.api.client.HelixZkClient _zkClient> = v;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.api.client.HelixZkClient _zkClient>;
v = new org.apache.helix.zookeeper.datamodel.serializer.ZNRecordSerializer;
specialinvoke v.<org.apache.helix.zookeeper.datamodel.serializer.ZNRecordSerializer: void <init>()>();
interfaceinvoke v.<org.apache.helix.zookeeper.api.client.HelixZkClient: void setZkSerializer(org.apache.helix.zookeeper.zkclient.serialize.ZkSerializer)>(v);
if v == null goto label;
v = virtualinvoke v.<java.lang.String: boolean isEmpty()>();
if v == 0 goto label;
label:
v = new java.lang.IllegalArgumentException;
specialinvoke v.<java.lang.IllegalArgumentException: void <init>(java.lang.String)>("lockBasePath cannot be null or empty!");
throw v;
label:
v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _basePath> = v;
v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.datamodel.ZNRecord _participantInfo> = v;
v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: boolean _isLeader> = 0;
exitmonitor v;
label:
goto label;
label:
v := @caughtexception;
exitmonitor v;
throw v;
label:
specialinvoke v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: void init()>();
return;
catch java.lang.Throwable from label to label with label;
}
private void init()
{
java.lang.Throwable v;
org.apache.zookeeper.CreateMode v;
java.lang.IllegalStateException v;
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
org.apache.helix.zookeeper.api.client.HelixZkClient v, v;
org.apache.helix.zookeeper.datamodel.ZNRecord v;
java.lang.String v, v, v, v, v, v, v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
label:
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.api.client.HelixZkClient _zkClient>;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _basePath>;
interfaceinvoke v.<org.apache.helix.zookeeper.api.client.HelixZkClient: void createPersistent(java.lang.String,boolean)>(v, 1);
label:
goto label;
label:
v := @caughtexception;
label:
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.api.client.HelixZkClient _zkClient>;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _basePath>;
v = dynamicinvoke "makeConcatWithConstants" <java.lang.String (java.lang.String)>(v) <java.lang.invoke.StringConcatFactory: java.lang.invoke.CallSite makeConcatWithConstants(java.lang.invoke.MethodHandles$Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.String,java.lang.Object[])>("\u0001/MSDS_SERVER_");
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.datamodel.ZNRecord _participantInfo>;
v = <org.apache.zookeeper.CreateMode: org.apache.zookeeper.CreateMode EPHEMERAL_SEQUENTIAL>;
v = interfaceinvoke v.<org.apache.helix.zookeeper.api.client.HelixZkClient: java.lang.String create(java.lang.String,java.lang.Object,org.apache.zookeeper.CreateMode)>(v, v, v);
v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _myEphemeralSequentialPath> = v;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _myEphemeralSequentialPath>;
if v != null goto label;
v = new java.lang.IllegalStateException;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _basePath>;
v = dynamicinvoke "makeConcatWithConstants" <java.lang.String (java.lang.String)>(v) <java.lang.invoke.StringConcatFactory: java.lang.invoke.CallSite makeConcatWithConstants(java.lang.invoke.MethodHandles$Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.String,java.lang.Object[])>("Unable to create ephemeral sequential node at path: \u0001");
specialinvoke v.<java.lang.IllegalStateException: void <init>(java.lang.String)>(v);
throw v;
label:
specialinvoke v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: void tryAcquiringLeadership()>();
return;
catch org.apache.helix.zookeeper.zkclient.exception.ZkNodeExistsException from label to label with label;
}
private void tryAcquiringLeadership()
{
java.lang.String[] v;
org.apache.helix.zookeeper.api.client.HelixZkClient v, v, v;
int v, v, v, v;
java.lang.String v, v, v, v, v, v, v;
boolean v;
org.slf4j.Logger v;
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
org.apache.helix.zookeeper.datamodel.ZNRecord v;
java.util.List v;
java.lang.Object v, v, v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.api.client.HelixZkClient _zkClient>;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _basePath>;
v = interfaceinvoke v.<org.apache.helix.zookeeper.api.client.HelixZkClient: java.util.List getChildren(java.lang.String)>(v);
staticinvoke <java.util.Collections: void sort(java.util.List)>(v);
v = interfaceinvoke v.<java.util.List: java.lang.Object get(int)>(0);
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.api.client.HelixZkClient _zkClient>;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _basePath>;
v = dynamicinvoke "makeConcatWithConstants" <java.lang.String (java.lang.String,java.lang.String)>(v, v) <java.lang.invoke.StringConcatFactory: java.lang.invoke.CallSite makeConcatWithConstants(java.lang.invoke.MethodHandles$Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.String,java.lang.Object[])>("\u0001/\u0001");
v = interfaceinvoke v.<org.apache.helix.zookeeper.api.client.HelixZkClient: java.lang.Object readData(java.lang.String,boolean)>(v, 1);
v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.datamodel.ZNRecord _currentLeaderInfo> = v;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _myEphemeralSequentialPath>;
v = virtualinvoke v.<java.lang.String: java.lang.String[] split(java.lang.String)>("/");
v = lengthof v;
v = v - 1;
v = v[v];
v = virtualinvoke v.<java.lang.String: boolean equals(java.lang.Object)>(v);
if v == 0 goto label;
v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: boolean _isLeader> = 1;
v = <org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.slf4j.Logger LOG>;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.datamodel.ZNRecord _currentLeaderInfo>;
interfaceinvoke v.<org.slf4j.Logger: void info(java.lang.String,java.lang.Object,java.lang.Object)>("{} acquired leadership! Info: {}", v, v);
goto label;
label:
v = interfaceinvoke v.<java.util.List: int indexOf(java.lang.Object)>(v);
v = v - 1;
v = interfaceinvoke v.<java.util.List: java.lang.Object get(int)>(v);
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.api.client.HelixZkClient _zkClient>;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: java.lang.String _basePath>;
v = dynamicinvoke "makeConcatWithConstants" <java.lang.String (java.lang.String,java.lang.String)>(v, v) <java.lang.invoke.StringConcatFactory: java.lang.invoke.CallSite makeConcatWithConstants(java.lang.invoke.MethodHandles$Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.String,java.lang.Object[])>("\u0001/\u0001");
interfaceinvoke v.<org.apache.helix.zookeeper.api.client.HelixZkClient: void subscribeDataChanges(java.lang.String,org.apache.helix.zookeeper.zkclient.IZkDataListener)>(v, v);
label:
return;
}
public synchronized boolean isLeader()
{
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
boolean v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: boolean _isLeader>;
return v;
}
public synchronized org.apache.helix.zookeeper.datamodel.ZNRecord getCurrentLeaderInfo()
{
org.apache.helix.zookeeper.datamodel.ZNRecord v;
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
v = v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.apache.helix.zookeeper.datamodel.ZNRecord _currentLeaderInfo>;
return v;
}
public synchronized void handleStateChanged(org.apache.zookeeper.Watcher$Event$KeeperState)
{
org.apache.zookeeper.Watcher$Event$KeeperState v, v;
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
v := @parameter: org.apache.zookeeper.Watcher$Event$KeeperState;
v = <org.apache.zookeeper.Watcher$Event$KeeperState: org.apache.zookeeper.Watcher$Event$KeeperState SyncConnected>;
if v != v goto label;
specialinvoke v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: void init()>();
label:
return;
}
public void handleNewSession(java.lang.String)
{
java.lang.String v;
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
v := @parameter: java.lang.String;
return;
}
public void handleSessionEstablishmentError(java.lang.Throwable)
{
java.lang.Throwable v;
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
v := @parameter: java.lang.Throwable;
return;
}
public void handleDataChange(java.lang.String, java.lang.Object)
{
java.lang.Object v;
java.lang.String v;
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
v := @parameter: java.lang.String;
v := @parameter: java.lang.Object;
return;
}
public void handleDataDeleted(java.lang.String)
{
java.lang.String v;
org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection v;
v := @this: org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection;
v := @parameter: java.lang.String;
specialinvoke v.<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: void tryAcquiringLeadership()>();
return;
}
static void <clinit>()
{
org.slf4j.Logger v;
v = staticinvoke <org.slf4j.LoggerFactory: org.slf4j.Logger getLogger(java.lang.Class)>(class "Lorg/apache/helix/rest/metadatastore/concurrency/ZkDistributedLeaderElection;");
<org.apache.helix.rest.metadatastore.concurrency.ZkDistributedLeaderElection: org.slf4j.Logger LOG> = v;
return;
}
}