forked from Ericsson/ecchronos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Ericsson#773 from VictorCavichioli/feature/jolokia
Fix Wrong Lock Configuration
- Loading branch information
Showing
7 changed files
with
232 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
target/ | ||
META-INF/ | ||
OSGI-INF/ | ||
build.properties | ||
pom.xml.versionsBackup | ||
dependency-reduced-pom.xml | ||
*~ | ||
*.bak | ||
.checkstyle | ||
.classpath | ||
.project | ||
.settings/ | ||
.toDelete | ||
*.pyc | ||
.idea/ | ||
*.iml | ||
.coverage | ||
*htmlcov | ||
application/statistics/ | ||
statistics/ | ||
.python-version |
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
60 changes: 60 additions & 0 deletions
60
...a/com/ericsson/bss/cassandra/ecchronos/core/impl/locks/CombinedRepairResourceFactory.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,60 @@ | ||
/* | ||
* Copyright 2024 Telefonaktiebolaget LM Ericsson | ||
* | ||
* Licensed 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 com.ericsson.bss.cassandra.ecchronos.core.impl.locks; | ||
|
||
import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairResource; | ||
import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairResourceFactory; | ||
import com.ericsson.bss.cassandra.ecchronos.core.state.ReplicaRepairGroup; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import com.google.common.collect.ImmutableSet; | ||
|
||
/** | ||
* Repair resource factory that creates a combination of repair resources based on other implementations. | ||
*/ | ||
public class CombinedRepairResourceFactory implements RepairResourceFactory | ||
{ | ||
private final ImmutableSet<RepairResourceFactory> myRepairResourceFactories; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param repairResourceFactories Repair resource factories | ||
*/ | ||
public CombinedRepairResourceFactory(final RepairResourceFactory... repairResourceFactories) | ||
{ | ||
myRepairResourceFactories = ImmutableSet.copyOf(repairResourceFactories); | ||
} | ||
|
||
/** | ||
* Get repair resources. | ||
* | ||
* @param replicaRepairGroup The replica repair group. | ||
* @return Repair resources | ||
*/ | ||
@Override | ||
public Set<RepairResource> getRepairResources(final ReplicaRepairGroup replicaRepairGroup) | ||
{ | ||
Set<RepairResource> repairResources = new HashSet<>(); | ||
|
||
for (RepairResourceFactory repairResourceFactory : myRepairResourceFactories) | ||
{ | ||
repairResources.addAll(repairResourceFactory.getRepairResources(replicaRepairGroup)); | ||
} | ||
|
||
return repairResources; | ||
} | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
...com/ericsson/bss/cassandra/ecchronos/core/impl/locks/DataCenterRepairResourceFactory.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,40 @@ | ||
/* | ||
* Copyright 2024 Telefonaktiebolaget LM Ericsson | ||
* | ||
* Licensed 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 com.ericsson.bss.cassandra.ecchronos.core.impl.locks; | ||
|
||
import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairResource; | ||
import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairResourceFactory; | ||
import com.ericsson.bss.cassandra.ecchronos.core.state.ReplicaRepairGroup; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Repair resource factory that generates one repair resource per data center involved in the repair. | ||
*/ | ||
public class DataCenterRepairResourceFactory implements RepairResourceFactory | ||
{ | ||
@Override | ||
public final Set<RepairResource> getRepairResources(final ReplicaRepairGroup replicaRepairGroup) | ||
{ | ||
return replicaRepairGroup.getDataCenters().stream() | ||
.map(this::dataCenterToRepairResource) | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
private RepairResource dataCenterToRepairResource(final String dataCenter) | ||
{ | ||
return new RepairResource(dataCenter, dataCenter); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...pl/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/impl/locks/RepairLockType.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,41 @@ | ||
/* | ||
* Copyright 2024 Telefonaktiebolaget LM Ericsson | ||
* | ||
* Licensed 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 com.ericsson.bss.cassandra.ecchronos.core.impl.locks; | ||
|
||
import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairResourceFactory; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* The type of locking to use for repair jobs. | ||
*/ | ||
public enum RepairLockType | ||
{ | ||
DATACENTER(DataCenterRepairResourceFactory::new), | ||
VNODE(VnodeRepairResourceFactory::new), | ||
DATACENTER_AND_VNODE(() -> new CombinedRepairResourceFactory(new DataCenterRepairResourceFactory(), | ||
new VnodeRepairResourceFactory())); | ||
|
||
private final Supplier<RepairResourceFactory> myRepairLockingFactoryProvider; | ||
|
||
RepairLockType(final Supplier<RepairResourceFactory> repairLockingProvider) | ||
{ | ||
myRepairLockingFactoryProvider = repairLockingProvider; | ||
} | ||
|
||
RepairResourceFactory getLockFactory() | ||
{ | ||
return myRepairLockingFactoryProvider.get(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...java/com/ericsson/bss/cassandra/ecchronos/core/impl/locks/VnodeRepairResourceFactory.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,42 @@ | ||
/* | ||
* Copyright 2024 Telefonaktiebolaget LM Ericsson | ||
* | ||
* Licensed 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 com.ericsson.bss.cassandra.ecchronos.core.impl.locks; | ||
|
||
import com.ericsson.bss.cassandra.ecchronos.core.metadata.DriverNode; | ||
import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairResource; | ||
import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairResourceFactory; | ||
import com.ericsson.bss.cassandra.ecchronos.core.state.ReplicaRepairGroup; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Repair resource factory that generates one repair resource per replica involved in the repair. | ||
*/ | ||
public class VnodeRepairResourceFactory implements RepairResourceFactory | ||
{ | ||
@Override | ||
public final Set<RepairResource> getRepairResources(final ReplicaRepairGroup replicaRepairGroup) | ||
{ | ||
return replicaRepairGroup.getReplicas().stream() | ||
.map(this::replicaToRepairResource) | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
private RepairResource replicaToRepairResource(final DriverNode node) | ||
{ | ||
return new RepairResource(node.getDatacenter(), node.getId().toString()); | ||
} | ||
} | ||
|