incubator-omid git commit: [OMID-87] Fix BatchPool initialization

2018-06-10 Thread ohads
Repository: incubator-omid
Updated Branches:
  refs/heads/master 3831330ba -> e3d7fe36b


[OMID-87] Fix BatchPool initialization

Added config.setMaxIdle(poolSize + 1) to the configuration.
Added some tests to prove it works.

Change-Id: Idc32ffa8472e87defdc540abbb901cfba700eb05


Project: http://git-wip-us.apache.org/repos/asf/incubator-omid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-omid/commit/e3d7fe36
Tree: http://git-wip-us.apache.org/repos/asf/incubator-omid/tree/e3d7fe36
Diff: http://git-wip-us.apache.org/repos/asf/incubator-omid/diff/e3d7fe36

Branch: refs/heads/master
Commit: e3d7fe36bbc32ed1eee633e4d92a0c4ba81a4e2e
Parents: 3831330
Author: Francisco Perez-Sorrosal 
Authored: Thu Feb 1 15:19:09 2018 -0800
Committer: Ohad Shacham 
Committed: Sun Jun 10 12:04:56 2018 +0300

--
 .../org/apache/omid/tso/BatchPoolModule.java|   6 +-
 .../java/org/apache/omid/tso/TestBatchPool.java | 128 +++
 2 files changed, 133 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/e3d7fe36/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
--
diff --git a/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java 
b/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
index c28f3aa..4e4c26a 100644
--- a/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
+++ b/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
@@ -52,11 +52,15 @@ public class BatchPoolModule extends AbstractModule {
 
 LOG.info("Pool Size (# of Batches) {}; Batch Size {}", poolSize, 
batchSize);
 LOG.info("Total Batch Size (Pool size * Batch Size): {}", poolSize * 
batchSize);
+// Setup ObjectPool behaviour
 GenericObjectPoolConfig config = new GenericObjectPoolConfig();
 config.setMaxTotal(poolSize);
+config.setMaxIdle(poolSize + 1); // This avoids GenericObjectPool to 
destroy the batches when returned to
+ // the pool during the pre-creation 
below
 config.setBlockWhenExhausted(true);
 GenericObjectPool batchPool = new GenericObjectPool<>(new 
Batch.BatchFactory(batchSize), config);
-LOG.info("Pre-creating objects in the pool..."); // TODO There should 
be a better way to do this
+LOG.info("Pre-creating objects in the pool...");
+// TODO There should be a better way to do the pre-creation below 
avoiding the two loops
 List batches = new ArrayList<>(poolSize);
 for (int i = 0; i < poolSize; i++) {
 batches.add(batchPool.borrowObject());

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/e3d7fe36/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java
--
diff --git a/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java 
b/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java
new file mode 100644
index 000..f4c1875
--- /dev/null
+++ b/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.omid.tso;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
+import org.apache.commons.pool2.ObjectPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+public class TestBatchPool {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(TestBatchPool.class);
+
+private static final int

[7/8] incubator-omid git commit: [OMID-87] Fix BatchPool initialization

2018-03-04 Thread ohads
[OMID-87] Fix BatchPool initialization

Added config.setMaxIdle(poolSize + 1) to the configuration.
Added some tests to prove it works.

Change-Id: Idc32ffa8472e87defdc540abbb901cfba700eb05


Project: http://git-wip-us.apache.org/repos/asf/incubator-omid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-omid/commit/57968cc1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-omid/tree/57968cc1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-omid/diff/57968cc1

Branch: refs/heads/0.9.0
Commit: 57968cc1d459161c7d29916fdc39cfe149629a30
Parents: fa7e2bc
Author: Francisco Perez-Sorrosal 
Authored: Thu Feb 1 15:19:09 2018 -0800
Committer: Francisco Perez-Sorrosal 
Committed: Wed Feb 14 10:15:47 2018 -0800

--
 .../org/apache/omid/tso/BatchPoolModule.java|   6 +-
 .../java/org/apache/omid/tso/TestBatchPool.java | 128 +++
 2 files changed, 133 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/57968cc1/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
--
diff --git a/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java 
b/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
index c28f3aa..4e4c26a 100644
--- a/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
+++ b/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
@@ -52,11 +52,15 @@ public class BatchPoolModule extends AbstractModule {
 
 LOG.info("Pool Size (# of Batches) {}; Batch Size {}", poolSize, 
batchSize);
 LOG.info("Total Batch Size (Pool size * Batch Size): {}", poolSize * 
batchSize);
+// Setup ObjectPool behaviour
 GenericObjectPoolConfig config = new GenericObjectPoolConfig();
 config.setMaxTotal(poolSize);
+config.setMaxIdle(poolSize + 1); // This avoids GenericObjectPool to 
destroy the batches when returned to
+ // the pool during the pre-creation 
below
 config.setBlockWhenExhausted(true);
 GenericObjectPool batchPool = new GenericObjectPool<>(new 
Batch.BatchFactory(batchSize), config);
-LOG.info("Pre-creating objects in the pool..."); // TODO There should 
be a better way to do this
+LOG.info("Pre-creating objects in the pool...");
+// TODO There should be a better way to do the pre-creation below 
avoiding the two loops
 List batches = new ArrayList<>(poolSize);
 for (int i = 0; i < poolSize; i++) {
 batches.add(batchPool.borrowObject());

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/57968cc1/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java
--
diff --git a/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java 
b/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java
new file mode 100644
index 000..f4c1875
--- /dev/null
+++ b/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.omid.tso;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
+import org.apache.commons.pool2.ObjectPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+public class TestBatchPool {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(TestBatchPool.class);
+
+private static final int CONCURRENT_WRITERS = 16;
+private static final int BATCH_SIZE = 1000;
+
+

incubator-omid git commit: [OMID-87] Fix BatchPool initialization

2018-02-14 Thread fperezsorrosal
Repository: incubator-omid
Updated Branches:
  refs/heads/0.9.0.0 fa7e2bccb -> 57968cc1d


[OMID-87] Fix BatchPool initialization

Added config.setMaxIdle(poolSize + 1) to the configuration.
Added some tests to prove it works.

Change-Id: Idc32ffa8472e87defdc540abbb901cfba700eb05


Project: http://git-wip-us.apache.org/repos/asf/incubator-omid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-omid/commit/57968cc1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-omid/tree/57968cc1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-omid/diff/57968cc1

Branch: refs/heads/0.9.0.0
Commit: 57968cc1d459161c7d29916fdc39cfe149629a30
Parents: fa7e2bc
Author: Francisco Perez-Sorrosal 
Authored: Thu Feb 1 15:19:09 2018 -0800
Committer: Francisco Perez-Sorrosal 
Committed: Wed Feb 14 10:15:47 2018 -0800

--
 .../org/apache/omid/tso/BatchPoolModule.java|   6 +-
 .../java/org/apache/omid/tso/TestBatchPool.java | 128 +++
 2 files changed, 133 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/57968cc1/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
--
diff --git a/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java 
b/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
index c28f3aa..4e4c26a 100644
--- a/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
+++ b/tso-server/src/main/java/org/apache/omid/tso/BatchPoolModule.java
@@ -52,11 +52,15 @@ public class BatchPoolModule extends AbstractModule {
 
 LOG.info("Pool Size (# of Batches) {}; Batch Size {}", poolSize, 
batchSize);
 LOG.info("Total Batch Size (Pool size * Batch Size): {}", poolSize * 
batchSize);
+// Setup ObjectPool behaviour
 GenericObjectPoolConfig config = new GenericObjectPoolConfig();
 config.setMaxTotal(poolSize);
+config.setMaxIdle(poolSize + 1); // This avoids GenericObjectPool to 
destroy the batches when returned to
+ // the pool during the pre-creation 
below
 config.setBlockWhenExhausted(true);
 GenericObjectPool batchPool = new GenericObjectPool<>(new 
Batch.BatchFactory(batchSize), config);
-LOG.info("Pre-creating objects in the pool..."); // TODO There should 
be a better way to do this
+LOG.info("Pre-creating objects in the pool...");
+// TODO There should be a better way to do the pre-creation below 
avoiding the two loops
 List batches = new ArrayList<>(poolSize);
 for (int i = 0; i < poolSize; i++) {
 batches.add(batchPool.borrowObject());

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/57968cc1/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java
--
diff --git a/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java 
b/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java
new file mode 100644
index 000..f4c1875
--- /dev/null
+++ b/tso-server/src/test/java/org/apache/omid/tso/TestBatchPool.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.omid.tso;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
+import org.apache.commons.pool2.ObjectPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+public class TestBatchPool {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(TestBatchPool.class);
+
+private st