ZKSessionLock implements SessionLock { static int parseMemberID(String nodeName) { int id = -1; String[] parts = nodeName.split("_"); if (parts.length > 0) { try { id = Integer.parseInt(parts[parts.length - 1]); } catch (NumberFormatException nfe) { id = Integer.MAX_VALUE; } } return id; } ZKSessionLock(ZooKeeperClient zkClient,
                  String lockPath,
                  String clientId,
                  OrderedScheduler lockStateExecutor);  ZKSessionLock(ZooKeeperClient zkClient,
                         String lockPath,
                         String clientId,
                         OrderedScheduler lockStateExecutor,
                         long lockOpTimeout,
                         StatsLogger statsLogger,
                         DistributedLockContext lockContext); static String getLockPathPrefixV1(String lockPath); static String getLockPathPrefixV2(String lockPath, String clientId); static String getLockPathPrefixV3(String lockPath, String clientId, long sessionOwner); static byte[] serializeClientId(String clientId); static String deserializeClientId(byte[] data); static String getLockIdFromPath(String path); @Override ZKSessionLock setLockListener(LockListener lockListener); boolean isLockExpired(); @Override boolean isLockHeld(); @Override Future<LockWaiter> asyncTryLock(final long timeout, final TimeUnit unit); @Override void tryLock(long timeout, TimeUnit unit); @Override Future<BoxedUnit> asyncUnlock(); @Override void unlock();  }
@Test(timeout = 60000) public void testParseMemberID() throws Exception { assertEquals(Integer.MAX_VALUE, parseMemberID("badnode")); assertEquals(Integer.MAX_VALUE, parseMemberID("badnode_badnode")); assertEquals(0, parseMemberID("member_000000")); assertEquals(123, parseMemberID("member_000123")); }