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
// initialize the client | |
UnlaunchClient client = UnlaunchClient.create("your_sdk_key"); | |
// get variation | |
String variation = client.getVariation("flag_key", "userID_123"); | |
// take action based on the returned variation | |
if (variation.equals("on")) { | |
// show the feature | |
} else if (variation.equals("off")) { |
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
class Task implements IdentifiableCallable<Boolean> { | |
private final int id; // Task Identifier | |
volatile boolean cancelled; // Cancellation flag | |
public Task(int id) { | |
this.id = id; | |
} | |
@Override |
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
/* A Custom Wrapper around FutureTask for returning Task Id. | |
* @author umermansoor | |
*/ | |
public abstract class FutureTaskWrapper<T> extends FutureTask<T> { | |
public FutureTaskWrapper(Callable<T> c) { | |
super(c); | |
} | |
abstract int getTaskId(); |
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
/** | |
* Custom Callable Interface with Id. | |
* @author umermansoor | |
*/ | |
public interface IdentifiableCallable extends Callable { | |
int getId(); // For getting task Id | |
void cancelTask(); // Method for supporting non-standard cancellation | |
RunnableFuture newTask(); | |
} |
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 CustomFutureReturningExecutor extends ThreadPoolExecutor { | |
public CustomFutureReturningExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue) { | |
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); | |
} | |
@Override | |
protected RunnableFuture newTaskFor(Callable callable) { | |
if (callable instanceof IdentifiableCallable) { | |
return ((IdentifiableCallable) callable).newTask(); |
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
class CancelleableSocketThread extends Thread { | |
@Override | |
public void interrupt() { | |
try { | |
server.close(); | |
} catch (IOException ignored) { |
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
class CancelleableSocketThread extends Thread { | |
@Override public void interrupt() { | |
try { | |
server.close(); | |
} catch (IOException ignored) { } | |
finally { super.interrupt(); } |
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
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home | |
export HADOOP_INSTALL=/Users/umermansoor/Documents/hadoop-1.1.1 | |
export PATH=$PATH:$HADOOP_INSTALL/bin |
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
<!-- exec plugin to run the python script which generates annotations --> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>exec-maven-plugin</artifactId> | |
<version>1.1.1</version> | |
<executions> | |
<execution> | |
<id>gen_ver_from_python</id> | |
<phase>generate-sources</phase> | |
<goals> |
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
<!-- Need this to detect source files in target/generated-sources folder --> | |
<!-- If used with a parent POM, the build-helper plugin stays with the child POM --> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>build-helper-maven-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>add-source</id> | |
<phase>generate-sources</phase> | |
<goals> |
NewerOlder