[GitHub] incubator-tephra pull request #2: TEPHRA-179 Create a new instance of Transa...

2016-09-07 Thread poornachandra
Github user poornachandra commented on a diff in the pull request:

https://github.com/apache/incubator-tephra/pull/2#discussion_r77906210
  
--- Diff: 
tephra-core/src/test/java/org/apache/tephra/distributed/ThriftTransactionServerTest.java
 ---
@@ -188,21 +224,35 @@ public void process(WatchedEvent event) {
 };
 
 // Create another Zookeeper session with the same sessionId so that 
the original one expires.
-final ZooKeeper dupZookeeper =
+ZooKeeper dupZookeeper =
   new ZooKeeper(zkClientService.getConnectString(), 
zooKeeper.getSessionTimeout(), watcher,
 zooKeeper.getSessionId(), 
zooKeeper.getSessionPasswd());
 connectFuture.get(30, TimeUnit.SECONDS);
 Assert.assertEquals("Failed to re-create current session", 
dupZookeeper.getState(), ZooKeeper.States.CONNECTED);
 dupZookeeper.close();
   }
 
-  private void waitForThriftTermination() throws InterruptedException {
-int count = 0;
-while (txService.thriftRPCServerState() != Service.State.TERMINATED && 
count++ < 200) {
+  private void waitFor(String errorMessage, Callable callable) 
throws Exception {
+for (int i = 0; i < 200; i++) {
+  boolean value = callable.call();
+  if (value) {
+return;
+  }
   TimeUnit.MILLISECONDS.sleep(50);
 }
+Assert.fail(errorMessage);
+  }
+
+  private void waitForThriftStatus() throws Exception {
--- End diff --

Rename to `waitForThriftStop` for clarity?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-tephra pull request #2: TEPHRA-179 Create a new instance of Transa...

2016-09-07 Thread poornachandra
Github user poornachandra commented on a diff in the pull request:

https://github.com/apache/incubator-tephra/pull/2#discussion_r77901080
  
--- Diff: 
tephra-core/src/main/java/org/apache/tephra/runtime/TransactionInMemoryModule.java
 ---
@@ -43,10 +44,12 @@ public TransactionInMemoryModule() {
 
   @Override
   protected void configure() {
-bind(SnapshotCodecProvider.class).in(Singleton.class);
-
bind(TransactionStateStorage.class).to(NoOpTransactionStateStorage.class).in(Singleton.class);
-bind(TransactionManager.class).in(Singleton.class);
-
bind(TransactionSystemClient.class).to(InMemoryTxSystemClient.class).in(Singleton.class);
+// some of these classes need to be non-singleton in order to create a 
new instance during leader() in
+// TransactionService
+bind(SnapshotCodecProvider.class).in(Scopes.SINGLETON);
+
bind(TransactionStateStorage.class).to(NoOpTransactionStateStorage.class);
+bind(TransactionManager.class);
+bind(TransactionSystemClient.class).to(InMemoryTxSystemClient.class);
--- End diff --

This also needs to be singleton


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-tephra pull request #2: TEPHRA-179 Create a new instance of Transa...

2016-09-07 Thread poornachandra
Github user poornachandra commented on a diff in the pull request:

https://github.com/apache/incubator-tephra/pull/2#discussion_r77899606
  
--- Diff: 
tephra-core/src/main/java/org/apache/tephra/runtime/TransactionDistributedModule.java
 ---
@@ -41,14 +41,15 @@
 
   @Override
   protected void configure() {
+// some of these classes need to be non-singleton in order to create a 
new instance during leader() in
+// TransactionService
 bind(SnapshotCodecProvider.class).in(Singleton.class);
-
bind(TransactionStateStorage.class).annotatedWith(Names.named("persist"))
-  .to(HDFSTransactionStateStorage.class).in(Singleton.class);
-
bind(TransactionStateStorage.class).toProvider(TransactionStateStorageProvider.class).in(Singleton.class);
+
bind(TransactionStateStorage.class).annotatedWith(Names.named("persist")).to(HDFSTransactionStateStorage.class);
+
bind(TransactionStateStorage.class).toProvider(TransactionStateStorageProvider.class);
 
-bind(TransactionManager.class).in(Singleton.class);
-
bind(TransactionSystemClient.class).to(TransactionServiceClient.class).in(Singleton.class);
-
bind(MetricsCollector.class).to(DefaultMetricsCollector.class).in(Singleton.class);
+bind(TransactionManager.class);
--- End diff --

This binding looks redundant now


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-tephra pull request #2: TEPHRA-179 Create a new instance of Transa...

2016-09-02 Thread anwar6953
GitHub user anwar6953 opened a pull request:

https://github.com/apache/incubator-tephra/pull/2

TEPHRA-179 Create a new instance of TransactionManager upon failover

Create a new instance of TransactionManager and related classes when 
TransactionService becomes leader.

https://issues.apache.org/jira/browse/TEPHRA-179

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/anwar6953/incubator-tephra 
fix/new-transaction-manager-upon-leader

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-tephra/pull/2.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2


commit c81f926d4a4552bed44afc06fa9e5d5ba1963898
Author: Ali Anwar 
Date:   2016-09-03T00:08:18Z

TEPHRA-179 Create a new instance of TransactionManager and related classes 
when TransactionService becomes leader.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---