This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.netflix.curator.framework.recipes.locks; | |
import com.google.common.util.concurrent.ThreadFactoryBuilder; | |
import com.netflix.curator.framework.CuratorFramework; | |
import org.apache.zookeeper.KeeperException; | |
import org.apache.zookeeper.data.Stat; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.io.Closeable; | |
import java.io.IOException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InterProcessSemaphoreMutex implements InterProcessLock | |
{ | |
private InterProcessSemaphore semaphore; | |
private volatile Lease lease; | |
public InterProcessSemaphoreMutex(InterProcessSemaphore semaphore) | |
{ | |
this.semaphore = semaphore; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void testKilledServerWithEnsembleProvider() throws Exception | |
{ | |
final int CLIENT_QTY = 10; | |
final Timing timing = new Timing(); | |
final String PATH = "/foo/bar/lock"; | |
ExecutorService executorService = Executors.newFixedThreadPool(CLIENT_QTY); | |
ExecutorCompletionService<Void> completionService = new ExecutorCompletionService<Void>(executorService); | |
TestingCluster cluster = new TestingCluster(3); | |
try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.io.Closeables; | |
import com.netflix.curator.framework.CuratorFramework; | |
import com.netflix.curator.framework.CuratorFrameworkFactory; | |
import com.netflix.curator.framework.api.BackgroundCallback; | |
import com.netflix.curator.framework.api.CuratorEvent; | |
import com.netflix.curator.retry.ExponentialBackoffRetry; | |
import com.netflix.curator.test.InstanceSpec; | |
import com.netflix.curator.test.TestingCluster; | |
import org.apache.zookeeper.AsyncCallback; | |
import org.apache.zookeeper.WatchedEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.base.Preconditions; | |
import com.google.common.collect.ImmutableList; | |
import com.google.common.collect.ImmutableMap; | |
import com.google.common.io.CharStreams; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.StringReader; | |
import java.net.Socket; | |
import java.util.List; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2012 Netflix, Inc. | |
* | |
* Licensed 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.netflix.curator.framework.recipes.nodes; | |
import com.google.common.annotations.VisibleForTesting; | |
import com.google.common.base.Objects; | |
import com.google.common.base.Preconditions; | |
import com.netflix.curator.framework.CuratorFramework; | |
import com.netflix.curator.framework.api.ACLBackgroundPathAndBytesable; | |
import com.netflix.curator.framework.api.BackgroundCallback; | |
import com.netflix.curator.framework.api.CreateModable; | |
import com.netflix.curator.framework.api.CuratorEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void offerOperation(final Operation operation) | |
{ | |
if ( operationsQuantizer.add(operation) ) | |
{ | |
submitToExecutor | |
( | |
new Runnable() | |
{ | |
@Override | |
public void run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.curator.framework.imps; | |
import com.google.common.cache.CacheBuilder; | |
import com.google.common.cache.CacheLoader; | |
import com.google.common.cache.LoadingCache; | |
import com.google.common.collect.Maps; | |
import com.google.common.collect.Sets; | |
import org.apache.zookeeper.ClientCnxn; | |
import org.apache.zookeeper.WatchedEvent; | |
import org.apache.zookeeper.Watcher; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final AtomicBoolean hasLeadership = new AtomicBoolean(false); | |
public LeaderSelector startParticipant(CuratorFramework client, int id) throws Exception { | |
LeaderSelector selector = null; | |
final int myid = id; | |
LeaderSelectorListener listener = new LeaderSelectorListener() | |
{ | |
volatile CountDownLatch holdLatch; | |
@Override |
OlderNewer