added transaction wrapper to REST declaration
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
package com.inteligr8.alfresco.asie.service;
|
package com.inteligr8.alfresco.asie.service;
|
||||||
|
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
|
||||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -24,23 +22,11 @@ public class ShardBackupService implements com.inteligr8.alfresco.asie.spi.Shard
|
|||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier(Constants.QUALIFIER_ASIE)
|
@Qualifier(Constants.QUALIFIER_ASIE)
|
||||||
private AttributeService attributeService;
|
private AttributeService attributeService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TransactionService txService;
|
|
||||||
|
|
||||||
@Value("${inteligr8.asie.backup.persistTimeMinutes}")
|
@Value("${inteligr8.asie.backup.persistTimeMinutes}")
|
||||||
private int persistTimeMinutes;
|
private int persistTimeMinutes;
|
||||||
|
|
||||||
public SolrHost selectNode(ShardSet shardSet, int shardId, SolrHost node) {
|
public SolrHost selectNode(ShardSet shardSet, int shardId, SolrHost node) {
|
||||||
return this.txService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<SolrHost>() {
|
|
||||||
@Override
|
|
||||||
public SolrHost execute() {
|
|
||||||
return selectNodeTx(shardSet, shardId, node);
|
|
||||||
}
|
|
||||||
}, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SolrHost selectNodeTx(ShardSet shardSet, int shardId, SolrHost node) {
|
|
||||||
String shardKey = shardSet.getCore() + "-" + shardId;
|
String shardKey = shardSet.getCore() + "-" + shardId;
|
||||||
|
|
||||||
PersistedNode backupNode = (PersistedNode) this.attributeService.getAttribute(Constants.ATTR_ASIE, ATTR_BACKUP_NODE, shardKey);
|
PersistedNode backupNode = (PersistedNode) this.attributeService.getAttribute(Constants.ATTR_ASIE, ATTR_BACKUP_NODE, shardKey);
|
||||||
@@ -55,30 +41,10 @@ public class ShardBackupService implements com.inteligr8.alfresco.asie.spi.Shard
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void forget() {
|
public void forget() {
|
||||||
this.txService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
|
|
||||||
@Override
|
|
||||||
public Void execute() {
|
|
||||||
forgetTx();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void forgetTx() {
|
|
||||||
this.attributeService.removeAttribute(Constants.ATTR_ASIE, ATTR_BACKUP_NODE);
|
this.attributeService.removeAttribute(Constants.ATTR_ASIE, ATTR_BACKUP_NODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forget(final ShardSet shardSet, final int shardId) {
|
public void forget(ShardSet shardSet, int shardId) {
|
||||||
this.txService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
|
|
||||||
@Override
|
|
||||||
public Void execute() {
|
|
||||||
forgetTx(shardSet, shardId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void forgetTx(ShardSet shardSet, int shardId) {
|
|
||||||
String shardKey = shardSet.getCore() + "-" + shardId;
|
String shardKey = shardSet.getCore() + "-" + shardId;
|
||||||
this.attributeService.removeAttribute(Constants.ATTR_ASIE, ATTR_BACKUP_NODE, shardKey);
|
this.attributeService.removeAttribute(Constants.ATTR_ASIE, ATTR_BACKUP_NODE, shardKey);
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,9 @@
|
|||||||
<!-- Security -->
|
<!-- Security -->
|
||||||
<authentication>none</authentication>
|
<authentication>none</authentication>
|
||||||
|
|
||||||
|
<!-- Transaction -->
|
||||||
|
<transaction>required</transaction>
|
||||||
|
|
||||||
<!-- Functionality -->
|
<!-- Functionality -->
|
||||||
<cache>
|
<cache>
|
||||||
<never>false</never>
|
<never>false</never>
|
||||||
|
@@ -34,6 +34,9 @@
|
|||||||
<!-- Security -->
|
<!-- Security -->
|
||||||
<authentication>none</authentication>
|
<authentication>none</authentication>
|
||||||
|
|
||||||
|
<!-- Transaction -->
|
||||||
|
<transaction>required</transaction>
|
||||||
|
|
||||||
<!-- Functionality -->
|
<!-- Functionality -->
|
||||||
<cache>
|
<cache>
|
||||||
<never>false</never>
|
<never>false</never>
|
||||||
|
@@ -31,6 +31,9 @@
|
|||||||
<!-- Security -->
|
<!-- Security -->
|
||||||
<authentication>admin</authentication>
|
<authentication>admin</authentication>
|
||||||
|
|
||||||
|
<!-- Transaction -->
|
||||||
|
<transaction>required</transaction>
|
||||||
|
|
||||||
<!-- Functionality -->
|
<!-- Functionality -->
|
||||||
<cache>
|
<cache>
|
||||||
<never>false</never>
|
<never>false</never>
|
||||||
|
@@ -34,6 +34,9 @@
|
|||||||
<!-- Security -->
|
<!-- Security -->
|
||||||
<authentication>admin</authentication>
|
<authentication>admin</authentication>
|
||||||
|
|
||||||
|
<!-- Transaction -->
|
||||||
|
<transaction>required</transaction>
|
||||||
|
|
||||||
<!-- Functionality -->
|
<!-- Functionality -->
|
||||||
<cache>
|
<cache>
|
||||||
<never>false</never>
|
<never>false</never>
|
||||||
|
@@ -32,6 +32,9 @@
|
|||||||
<!-- Security -->
|
<!-- Security -->
|
||||||
<authentication>admin</authentication>
|
<authentication>admin</authentication>
|
||||||
|
|
||||||
|
<!-- Transaction -->
|
||||||
|
<transaction>required</transaction>
|
||||||
|
|
||||||
<!-- Functionality -->
|
<!-- Functionality -->
|
||||||
<cache>
|
<cache>
|
||||||
<never>false</never>
|
<never>false</never>
|
||||||
|
@@ -23,6 +23,9 @@
|
|||||||
<!-- Security -->
|
<!-- Security -->
|
||||||
<authentication>admin</authentication>
|
<authentication>admin</authentication>
|
||||||
|
|
||||||
|
<!-- Transaction -->
|
||||||
|
<transaction>required</transaction>
|
||||||
|
|
||||||
<!-- Functionality -->
|
<!-- Functionality -->
|
||||||
<cache>
|
<cache>
|
||||||
<never>false</never>
|
<never>false</never>
|
||||||
|
Reference in New Issue
Block a user