You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/09/27 09:21:39 UTC
[1/2] james-project git commit: JAMES-2544 The slice identifier
should not incorporate duration
Repository: james-project
Updated Branches:
refs/heads/master b70ca1a7c -> e3bdf9b6a
JAMES-2544 The slice identifier should not incorporate duration
Because we use only start timestamp qs an ID in cassandra, using duration
as part of slice is really confusing
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8a5677fe
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8a5677fe
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8a5677fe
Branch: refs/heads/master
Commit: 8a5677fed21860ba845fb5f062b044080fdc3a91
Parents: b70ca1a
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Sep 26 08:27:45 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Wed Sep 26 09:27:41 2018 +0700
----------------------------------------------------------------------
.../cassandra/CassandraMailQueueBrowser.java | 4 +--
.../view/cassandra/model/BucketedSlices.java | 29 ++++++++------------
.../view/cassandra/EnqueuedMailsDaoTest.java | 3 +-
.../cassandra/model/BucketedSlicesTest.java | 24 ++++++++--------
4 files changed, 26 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/8a5677fe/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
index 21dedb8..176d2b7 100644
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
@@ -115,8 +115,8 @@ class CassandraMailQueueBrowser {
private Stream<Slice> allSlicesStartingAt(Optional<Instant> maybeBrowseStart) {
return maybeBrowseStart
- .map(browseStart -> Slice.of(browseStart, configuration.getSliceWindow()))
- .map(startSlice -> allSlicesTill(startSlice, clock.instant()))
+ .map(Slice::of)
+ .map(startSlice -> allSlicesTill(startSlice, clock.instant(), configuration.getSliceWindow()))
.orElse(Stream.empty());
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/8a5677fe/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlices.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlices.java b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlices.java
index 1f5d3d5..d35b6d7 100644
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlices.java
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlices.java
@@ -65,22 +65,22 @@ public class BucketedSlices {
public static class Slice {
- public static Slice of(Instant sliceStartInstant, Duration sliceWindowSize) {
- return new Slice(sliceStartInstant, sliceWindowSize);
+ public static Slice of(Instant sliceStartInstant) {
+ return new Slice(sliceStartInstant);
}
- public static Stream<Slice> allSlicesTill(Slice firstSlice, Instant endAt) {
- long sliceCount = calculateSliceCount(firstSlice, endAt);
+ public static Stream<Slice> allSlicesTill(Slice firstSlice, Instant endAt, Duration windowSize) {
+ long sliceCount = calculateSliceCount(firstSlice, endAt, windowSize);
long startAtSeconds = firstSlice.getStartSliceInstant().getEpochSecond();
- long sliceWindowSizeInSecond = firstSlice.getSliceWindowSize().getSeconds();
+ long sliceWindowSizeInSecond = windowSize.getSeconds();
return LongStream.range(0, sliceCount)
.map(slicePosition -> startAtSeconds + sliceWindowSizeInSecond * slicePosition)
.mapToObj(Instant::ofEpochSecond)
- .map(sliceStartInstant -> Slice.of(sliceStartInstant, firstSlice.getSliceWindowSize()));
+ .map(Slice::of);
}
- private static long calculateSliceCount(Slice firstSlice, Instant endAt) {
+ private static long calculateSliceCount(Slice firstSlice, Instant endAt, Duration windowSize) {
long startAtSeconds = firstSlice.getStartSliceInstant().getEpochSecond();
long endAtSeconds = endAt.getEpochSecond();
long timeDiffInSecond = endAtSeconds - startAtSeconds;
@@ -88,43 +88,36 @@ public class BucketedSlices {
if (timeDiffInSecond < 0) {
return 0;
} else {
- return (timeDiffInSecond / firstSlice.getSliceWindowSize().getSeconds()) + 1;
+ return (timeDiffInSecond / windowSize.getSeconds()) + 1;
}
}
private final Instant startSliceInstant;
- private final Duration sliceWindowSize;
- private Slice(Instant startSliceInstant, Duration sliceWindowSize) {
+ private Slice(Instant startSliceInstant) {
Preconditions.checkNotNull(startSliceInstant);
- Preconditions.checkNotNull(sliceWindowSize);
this.startSliceInstant = startSliceInstant;
- this.sliceWindowSize = sliceWindowSize;
}
public Instant getStartSliceInstant() {
return startSliceInstant;
}
- public Duration getSliceWindowSize() {
- return sliceWindowSize;
- }
@Override
public final boolean equals(Object o) {
if (o instanceof Slice) {
Slice slice = (Slice) o;
- return Objects.equals(this.sliceWindowSize, slice.sliceWindowSize)
- && Objects.equals(this.startSliceInstant, slice.startSliceInstant);
+ return Objects.equals(this.startSliceInstant, slice.startSliceInstant);
}
return false;
}
@Override
public final int hashCode() {
- return Objects.hash(startSliceInstant, sliceWindowSize);
+ return Objects.hash(startSliceInstant);
}
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/8a5677fe/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java
index 94a80a3..f649a48 100644
--- a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java
+++ b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java
@@ -23,7 +23,6 @@ import static org.apache.james.queue.rabbitmq.view.cassandra.model.BucketedSlice
import static org.apache.james.queue.rabbitmq.view.cassandra.model.BucketedSlices.Slice;
import static org.assertj.core.api.Assertions.assertThat;
-import java.time.Duration;
import java.time.Instant;
import java.util.stream.Stream;
@@ -46,7 +45,7 @@ class EnqueuedMailsDaoTest {
private static int BUCKET_ID_VALUE = 10;
private static final BucketId BUCKET_ID = BucketId.of(BUCKET_ID_VALUE);
private static final Instant NOW = Instant.now();
- private static final Slice SLICE_OF_NOW = Slice.of(NOW, Duration.ofSeconds(100));
+ private static final Slice SLICE_OF_NOW = Slice.of(NOW);
@RegisterExtension
static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraMailQueueViewModule.MODULE);
http://git-wip-us.apache.org/repos/asf/james-project/blob/8a5677fe/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlicesTest.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlicesTest.java b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlicesTest.java
index 5386050..842216c 100644
--- a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlicesTest.java
+++ b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/model/BucketedSlicesTest.java
@@ -41,8 +41,8 @@ class BucketedSlicesTest {
private static final Instant FIRST_SLICE_INSTANT_NEXT_TWO_HOUR = FIRST_SLICE_INSTANT.plusSeconds(ONE_HOUR_IN_SECONDS * 2);
private static final Duration ONE_HOUR_SLICE_WINDOW = Duration.ofSeconds(ONE_HOUR_IN_SECONDS);
- private static final Slice FIRST_SLICE = Slice.of(FIRST_SLICE_INSTANT, ONE_HOUR_SLICE_WINDOW);
- private static final Slice FIRST_SLICE_NEXT_TWO_HOUR = Slice.of(FIRST_SLICE_INSTANT_NEXT_TWO_HOUR, Duration.ofSeconds(ONE_HOUR_IN_SECONDS));
+ private static final Slice FIRST_SLICE = Slice.of(FIRST_SLICE_INSTANT);
+ private static final Slice FIRST_SLICE_NEXT_TWO_HOUR = Slice.of(FIRST_SLICE_INSTANT_NEXT_TWO_HOUR);
@Test
void bucketIdShouldMatchBeanContract() {
@@ -64,31 +64,31 @@ class BucketedSlicesTest {
@Test
void allSlicesTillShouldReturnOnlyFirstSliceWhenEndAtInTheSameInterval() {
- assertThat(Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT.plusSeconds(ONE_HOUR_IN_SECONDS - 1)))
+ assertThat(Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT.plusSeconds(ONE_HOUR_IN_SECONDS - 1), ONE_HOUR_SLICE_WINDOW))
.containsOnly(FIRST_SLICE);
}
@Test
void allSlicesTillShouldReturnAllSlicesBetweenStartAndEndAt() {
- Stream<Slice> allSlices = Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT_NEXT_TWO_HOUR.plusSeconds(ONE_HOUR_IN_SECONDS - 1));
+ Stream<Slice> allSlices = Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT_NEXT_TWO_HOUR.plusSeconds(ONE_HOUR_IN_SECONDS - 1), ONE_HOUR_SLICE_WINDOW);
assertThat(allSlices)
.containsExactly(
FIRST_SLICE,
- Slice.of(FIRST_SLICE_INSTANT_NEXT_HOUR, ONE_HOUR_SLICE_WINDOW),
- Slice.of(FIRST_SLICE_INSTANT_NEXT_TWO_HOUR, ONE_HOUR_SLICE_WINDOW));
+ Slice.of(FIRST_SLICE_INSTANT_NEXT_HOUR),
+ Slice.of(FIRST_SLICE_INSTANT_NEXT_TWO_HOUR));
}
@Test
void allSlicesTillShouldReturnSameSlicesWhenEndAtsAreInTheSameInterval() {
- Stream<Slice> allSlicesEndAtTheStartOfWindow = Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT_NEXT_TWO_HOUR);
- Stream<Slice> allSlicesEndAtTheMiddleOfWindow = Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT_NEXT_TWO_HOUR.plusSeconds(1000));
- Stream<Slice> allSlicesEndAtTheEndWindow = Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT_NEXT_TWO_HOUR.plusSeconds(ONE_HOUR_IN_SECONDS - 1));
+ Stream<Slice> allSlicesEndAtTheStartOfWindow = Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT_NEXT_TWO_HOUR, ONE_HOUR_SLICE_WINDOW);
+ Stream<Slice> allSlicesEndAtTheMiddleOfWindow = Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT_NEXT_TWO_HOUR.plusSeconds(1000), ONE_HOUR_SLICE_WINDOW);
+ Stream<Slice> allSlicesEndAtTheEndWindow = Slice.allSlicesTill(FIRST_SLICE, FIRST_SLICE_INSTANT_NEXT_TWO_HOUR.plusSeconds(ONE_HOUR_IN_SECONDS - 1), ONE_HOUR_SLICE_WINDOW);
Slice [] allSlicesInThreeHours = {
FIRST_SLICE,
- Slice.of(FIRST_SLICE_INSTANT_NEXT_HOUR, ONE_HOUR_SLICE_WINDOW),
- Slice.of(FIRST_SLICE_INSTANT_NEXT_TWO_HOUR, ONE_HOUR_SLICE_WINDOW)};
+ Slice.of(FIRST_SLICE_INSTANT_NEXT_HOUR),
+ Slice.of(FIRST_SLICE_INSTANT_NEXT_TWO_HOUR)};
assertThat(allSlicesEndAtTheStartOfWindow)
.containsExactly(allSlicesInThreeHours);
@@ -102,7 +102,7 @@ class BucketedSlicesTest {
@Test
void allSlicesTillShouldReturnEmptyIfEndAtBeforeStartSlice() {
- Stream<Slice> allSlices = Slice.allSlicesTill(FIRST_SLICE_NEXT_TWO_HOUR, FIRST_SLICE_INSTANT);
+ Stream<Slice> allSlices = Slice.allSlicesTill(FIRST_SLICE_NEXT_TWO_HOUR, FIRST_SLICE_INSTANT, ONE_HOUR_SLICE_WINDOW);
assertThat(allSlices).isEmpty();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[2/2] james-project git commit: Documentation update about pom.xml
ordering rules
Posted by bt...@apache.org.
Documentation update about pom.xml ordering rules
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e3bdf9b6
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e3bdf9b6
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e3bdf9b6
Branch: refs/heads/master
Commit: e3bdf9b6a9f070a244b896752fdcb32e60b93e64
Parents: 8a5677f
Author: Matthieu Baechler <ma...@apache.org>
Authored: Thu Sep 27 10:46:02 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Sep 27 16:20:53 2018 +0700
----------------------------------------------------------------------
src/site/xdoc/contribute.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/e3bdf9b6/src/site/xdoc/contribute.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/contribute.xml b/src/site/xdoc/contribute.xml
index 25e5a0c..1cb9fc1 100644
--- a/src/site/xdoc/contribute.xml
+++ b/src/site/xdoc/contribute.xml
@@ -244,7 +244,7 @@ Here is some more details about what my commit does, and the rationals of the ch
<ul>
<li>Define your dependency versions in james-project pom.xml. This structurally ensures all projects get the
same version, and that there is no version clashes.</li>
- <li>Don't use <i>org.apache.james</i> groupId for your dependencies. Use <i>${project.groupId}</i>.
+ <li>Don't use <i>org.apache.james</i> groupId for your dependencies. Use <i>${james.groupId}</i>.
If not, you break the policies for automatic sorting, as well as make it more ambiguous.</li>
<li>You should be ordering your dependencies. The sort order is:
<ul>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org