This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODULE: Extract out TX grouping factories.
- Loading branch information
1 parent
7a3d45c
commit 35b072e
Showing
7 changed files
with
196 additions
and
20 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
36 changes: 36 additions & 0 deletions
36
.../org/apache/geode/cache/wan/internal/txgrouping/CommonTxGroupingGatewaySenderFactory.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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.geode.cache.wan.internal.txgrouping; | ||
|
||
import static java.lang.String.format; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import org.apache.geode.cache.wan.internal.GatewaySenderTypeFactory; | ||
import org.apache.geode.internal.cache.wan.GatewaySenderException; | ||
import org.apache.geode.internal.cache.wan.MutableGatewaySenderAttributes; | ||
|
||
public abstract class CommonTxGroupingGatewaySenderFactory { | ||
public static void validate(final @NotNull GatewaySenderTypeFactory factory, | ||
final @NotNull MutableGatewaySenderAttributes attributes) { | ||
if (attributes.isBatchConflationEnabled()) { | ||
throw new GatewaySenderException( | ||
format( | ||
"%s %s cannot be created with both group transaction events set to true and batch conflation enabled", | ||
factory.getType(), attributes.getId())); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...de/cache/wan/internal/txgrouping/parallel/TxGroupingParallelGatewaySenderTypeFactory.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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.geode.cache.wan.internal.txgrouping.parallel; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import org.apache.geode.cache.wan.GatewaySender; | ||
import org.apache.geode.cache.wan.internal.parallel.ParallelGatewaySenderImpl; | ||
import org.apache.geode.cache.wan.internal.parallel.ParallelGatewaySenderTypeFactory; | ||
import org.apache.geode.cache.wan.internal.txgrouping.CommonTxGroupingGatewaySenderFactory; | ||
import org.apache.geode.internal.cache.InternalCache; | ||
import org.apache.geode.internal.cache.wan.GatewaySenderAttributes; | ||
import org.apache.geode.internal.cache.wan.GatewaySenderException; | ||
import org.apache.geode.internal.cache.wan.MutableGatewaySenderAttributes; | ||
import org.apache.geode.internal.cache.xmlcache.ParallelGatewaySenderCreation; | ||
import org.apache.geode.internal.statistics.StatisticsClock; | ||
|
||
public class TxGroupingParallelGatewaySenderTypeFactory extends ParallelGatewaySenderTypeFactory { | ||
|
||
@Override | ||
public @NotNull String getType() { | ||
return "TxGroupingParallelGatewaySender"; | ||
} | ||
|
||
@Override | ||
public void validate(final @NotNull MutableGatewaySenderAttributes attributes) | ||
throws GatewaySenderException { | ||
super.validate(attributes); | ||
|
||
CommonTxGroupingGatewaySenderFactory.validate(this, attributes); | ||
} | ||
|
||
@Override | ||
public GatewaySender create(final @NotNull InternalCache cache, | ||
final @NotNull StatisticsClock clock, | ||
final @NotNull GatewaySenderAttributes attributes) { | ||
return new ParallelGatewaySenderImpl(cache, clock, attributes); | ||
} | ||
|
||
@Override | ||
public GatewaySender createCreation(final @NotNull InternalCache cache, | ||
final @NotNull GatewaySenderAttributes attributes) { | ||
return new ParallelGatewaySenderCreation(cache, attributes); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
.../geode/cache/wan/internal/txgrouping/serial/TxGroupingSerialGatewaySenderTypeFactory.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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.geode.cache.wan.internal.txgrouping.serial; | ||
|
||
import static java.lang.String.format; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import org.apache.geode.cache.wan.GatewaySender; | ||
import org.apache.geode.cache.wan.internal.serial.SerialGatewaySenderImpl; | ||
import org.apache.geode.cache.wan.internal.serial.SerialGatewaySenderTypeFactory; | ||
import org.apache.geode.cache.wan.internal.txgrouping.CommonTxGroupingGatewaySenderFactory; | ||
import org.apache.geode.internal.cache.InternalCache; | ||
import org.apache.geode.internal.cache.wan.GatewaySenderAttributes; | ||
import org.apache.geode.internal.cache.wan.GatewaySenderException; | ||
import org.apache.geode.internal.cache.wan.MutableGatewaySenderAttributes; | ||
import org.apache.geode.internal.cache.xmlcache.SerialGatewaySenderCreation; | ||
import org.apache.geode.internal.statistics.StatisticsClock; | ||
|
||
public class TxGroupingSerialGatewaySenderTypeFactory extends SerialGatewaySenderTypeFactory { | ||
|
||
@Override | ||
public @NotNull String getType() { | ||
return "TxGroupingSerialGatewaySender"; | ||
} | ||
|
||
@Override | ||
public void validate(final @NotNull MutableGatewaySenderAttributes attributes) | ||
throws GatewaySenderException { | ||
|
||
super.validate(attributes); | ||
|
||
CommonTxGroupingGatewaySenderFactory.validate(this, attributes); | ||
|
||
if (attributes.getDispatcherThreads() > 1) { | ||
throw new GatewaySenderException( | ||
format( | ||
"%s %s cannot be created with group transaction events set to true when dispatcher threads is greater than 1", | ||
getType(), attributes.getId())); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public GatewaySender create(final @NotNull InternalCache cache, | ||
final @NotNull StatisticsClock clock, | ||
final @NotNull GatewaySenderAttributes attributes) { | ||
return new SerialGatewaySenderImpl(cache, clock, attributes); | ||
} | ||
|
||
@Override | ||
public GatewaySender createCreation(final @NotNull InternalCache cache, | ||
final @NotNull GatewaySenderAttributes attributes) { | ||
return new SerialGatewaySenderCreation(cache, attributes); | ||
} | ||
|
||
} |