Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAILBOX-332 Cassandra implementation for Quota Threshold Crossing not…
…ification
- Loading branch information
Showing
32 changed files
with
1,488 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,135 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!-- | |||
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. | |||
--> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
|
|||
<parent> | |||
<artifactId>apache-james-mailbox</artifactId> | |||
<groupId>org.apache.james</groupId> | |||
<version>3.1.0-SNAPSHOT</version> | |||
<relativePath>../../pom.xml</relativePath> | |||
</parent> | |||
|
|||
<artifactId>quota-mailing-cassandra</artifactId> | |||
<name>Apache James :: Mailbox :: Plugin :: Quota Mailing :: Cassandra</name> | |||
<description>Apache James Mailbox Cassandra implementation of Quota mailing listener</description> | |||
|
|||
<dependencies> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>apache-james-backends-cassandra</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>apache-james-backends-cassandra</artifactId> | |||
<type>test-jar</type> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>apache-james-mailbox-api</artifactId> | |||
<type>test-jar</type> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>apache-james-mailbox-quota-mailing</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>apache-james-mailbox-quota-mailing</artifactId> | |||
<type>test-jar</type> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>apache-james-mailbox-store</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>apache-mailet-base</artifactId> | |||
<type>test-jar</type> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>james-server-data-memory</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>ch.qos.logback</groupId> | |||
<artifactId>logback-classic</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.assertj</groupId> | |||
<artifactId>assertj-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.fasterxml.jackson.core</groupId> | |||
<artifactId>jackson-databind</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.fasterxml.jackson.datatype</groupId> | |||
<artifactId>jackson-datatype-jdk8</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>net.javacrumbs.json-unit</groupId> | |||
<artifactId>json-unit</artifactId> | |||
<version>1.5.5</version> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>net.javacrumbs.json-unit</groupId> | |||
<artifactId>json-unit-fluent</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>nl.jqno.equalsverifier</groupId> | |||
<artifactId>equalsverifier</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.junit.jupiter</groupId> | |||
<artifactId>junit-jupiter-engine</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.junit.platform</groupId> | |||
<artifactId>junit-platform-launcher</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.testcontainers</groupId> | |||
<artifactId>testcontainers</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
|
|||
</project> |
62 changes: 62 additions & 0 deletions
62
...cassandra/src/main/java/org/apache/james/eventsourcing/cassandra/CassandraEventStore.java
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,62 @@ | |||
/**************************************************************** | |||
* 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.james.eventsourcing.cassandra; | |||
|
|||
import java.util.List; | |||
|
|||
import javax.inject.Inject; | |||
|
|||
import org.apache.james.eventsourcing.AggregateId; | |||
import org.apache.james.eventsourcing.Event; | |||
import org.apache.james.eventsourcing.EventStore; | |||
|
|||
import com.google.common.base.Preconditions; | |||
|
|||
public class CassandraEventStore implements EventStore { | |||
|
|||
private final EventStoreDao eventStoreDao; | |||
|
|||
@Inject | |||
public CassandraEventStore(EventStoreDao eventStoreDao) { | |||
this.eventStoreDao = eventStoreDao; | |||
} | |||
|
|||
@Override | |||
public void appendAll(List<Event> events) { | |||
if (events.isEmpty()) { | |||
return; | |||
} | |||
doAppendAll(events); | |||
} | |||
|
|||
public void doAppendAll(List<Event> events) { | |||
Preconditions.checkArgument(Event.belongsToSameAggregate(events)); | |||
|
|||
boolean success = eventStoreDao.appendAll(events).join(); | |||
if (!success) { | |||
throw new EventStoreFailedException(); | |||
} | |||
} | |||
|
|||
@Override | |||
public History getEventsOfAggregate(AggregateId aggregateId) { | |||
return eventStoreDao.getEventsOfAggregate(aggregateId); | |||
} | |||
} |
62 changes: 62 additions & 0 deletions
62
...dra/src/main/java/org/apache/james/eventsourcing/cassandra/CassandraEventStoreModule.java
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,62 @@ | |||
/**************************************************************** | |||
* 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.james.eventsourcing.cassandra; | |||
|
|||
import java.util.List; | |||
|
|||
import org.apache.james.backends.cassandra.components.CassandraModule; | |||
import org.apache.james.backends.cassandra.components.CassandraTable; | |||
import org.apache.james.backends.cassandra.components.CassandraType; | |||
import org.apache.james.backends.cassandra.utils.CassandraConstants; | |||
|
|||
import com.datastax.driver.core.DataType; | |||
import com.datastax.driver.core.schemabuilder.SchemaBuilder; | |||
import com.google.common.collect.ImmutableList; | |||
|
|||
public class CassandraEventStoreModule implements CassandraModule { | |||
private final List<CassandraTable> tables; | |||
private final List<CassandraType> types; | |||
|
|||
public CassandraEventStoreModule() { | |||
tables = ImmutableList.of( | |||
new CassandraTable(CassandraEventStoreTable.EVENTS_TABLE, | |||
SchemaBuilder.createTable(CassandraEventStoreTable.EVENTS_TABLE) | |||
.ifNotExists() | |||
.addPartitionKey(CassandraEventStoreTable.AGGREGATE_ID, DataType.varchar()) | |||
.addClusteringColumn(CassandraEventStoreTable.EVENT_ID, DataType.cint()) | |||
.addColumn(CassandraEventStoreTable.EVENT, DataType.text()) | |||
.withOptions() | |||
.comment("Store events of a EventSourcing aggregate") | |||
.caching(SchemaBuilder.KeyCaching.ALL, | |||
SchemaBuilder.rows(CassandraConstants.DEFAULT_CACHED_ROW_PER_PARTITION)))); | |||
types = ImmutableList.of(); | |||
} | |||
|
|||
@Override | |||
public List<CassandraTable> moduleTables() { | |||
return tables; | |||
} | |||
|
|||
@Override | |||
public List<CassandraType> moduleTypes() { | |||
return types; | |||
} | |||
|
|||
} |
27 changes: 27 additions & 0 deletions
27
...ndra/src/main/java/org/apache/james/eventsourcing/cassandra/CassandraEventStoreTable.java
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
/**************************************************************** | |||
* 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.james.eventsourcing.cassandra; | |||
|
|||
public interface CassandraEventStoreTable { | |||
String EVENTS_TABLE = "eventStore"; | |||
String AGGREGATE_ID = "aggregateId"; | |||
String EVENT = "event"; | |||
String EVENT_ID = "eventId"; | |||
} |
Oops, something went wrong.