Skip to content

Commit

Permalink
Merge pull request Ericsson#773 from VictorCavichioli/feature/jolokia
Browse files Browse the repository at this point in the history
Fix Wrong Lock Configuration
  • Loading branch information
SajidRiaz138 authored Nov 21, 2024
2 parents 66c052c + 602b1a4 commit 4554d61
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 20 deletions.
21 changes: 21 additions & 0 deletions .gitignore
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package com.ericsson.bss.cassandra.ecchronos.application.config.repair;

import com.ericsson.bss.cassandra.ecchronos.application.spring.AbstractRepairConfigurationProvider;
import com.ericsson.bss.cassandra.ecchronos.core.impl.locks.RepairLockType;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Locale;
import org.springframework.context.ApplicationContext;

import java.util.concurrent.TimeUnit;
Expand All @@ -28,6 +30,7 @@ public class GlobalRepairConfig extends RepairConfig
FileBasedRepairConfiguration.class;
private Interval myRepairHistoryLookback = new Interval(THIRTY_DAYS, TimeUnit.DAYS);
private RepairHistory myRepairHistory = new RepairHistory();
private RepairLockType myRepairLockType = RepairLockType.VNODE;

@JsonProperty("provider")
public final Class<? extends AbstractRepairConfigurationProvider> getRepairConfigurationClass()
Expand Down Expand Up @@ -67,5 +70,17 @@ public final void setRepairHistory(final RepairHistory repairHistory)
{
myRepairHistory = repairHistory;
}

@JsonProperty("lock_type")
public final RepairLockType getRepairLockType()
{
return myRepairLockType;
}

@JsonProperty("lock_type")
public final void setRepairLockType(final String repairLockType)
{
myRepairLockType = RepairLockType.valueOf(repairLockType.toUpperCase(Locale.US));
}
}

33 changes: 13 additions & 20 deletions application/src/main/resources/ecc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ connection:
connectionDelay:
time: 45
unit: MINUTES
##
## Allow routing requests directly to a remote datacenter.
## This allows locks for other datacenters to be taken in that datacenter instead of via the local datacenter.
## If clients are prevented from connecting directly to Cassandra nodes in other sites this is not possible.
## If remote routing is disabled, instead SERIAL consistency will be used for those request.
##
remoteRouting: true
jmx:
##
## The class used to provide JMX connections to Apache Cassandra.
Expand Down Expand Up @@ -278,19 +271,19 @@ rest_server:
host: localhost
port: 8080

lock_factory:
cas:
##
## The keyspace used for the CAS lock factory tables.
##
keyspace: ecchronos
##
## The number of seconds until the lock failure cache expires.
## If an attempt to secure a lock is unsuccessful,
## all subsequent attempts will be failed until
## the cache expiration time is reached.
##
cache_expiry_time_in_seconds: 30
lock_factory:
cas:
##
## The keyspace used for the CAS lock factory tables.
##
keyspace: ecchronos
##
## The number of seconds until the lock failure cache expires.
## If an attempt to secure a lock is unsuccessful,
## all subsequent attempts will be failed until
## the cache expiration time is reached.
##
cache_expiry_time_in_seconds: 30
##
## Allow to override consistency level for LWT (lightweight transactions). Possible values are:
## "DEFAULT" - Use consistency level based on the `datacenterAware` agent type.
Expand Down
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;
}
}

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);
}
}
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();
}
}
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());
}
}

0 comments on commit 4554d61

Please sign in to comment.