-package org.openecomp.sdc.be.dao.titan.transactions;
+package org.openecomp.sdc.be.dao.janusgraph.transactions;
-import com.thinkaurelius.titan.core.TitanException;
-import com.thinkaurelius.titan.core.TitanGraph;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.janusgraph.core.JanusGraphException;
+import org.janusgraph.core.JanusGraph;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import javax.annotation.PostConstruct;
/**
- * Simple transaction manager for the titan database.
+ * Simple transaction manager for the janusgraph database.
* This manager does not deal with transactions propagation and relies on the fact that transactions are automatically created with the first operation on the graph
*/
@Component
-public class SimpleTitanTransactionManager implements PlatformTransactionManager {
+public class SimpleJanusGraphTransactionManager implements PlatformTransactionManager {
- private static final Logger log = Logger.getLogger(SimpleTitanTransactionManager.class.getName());
- private final TitanGraphClient titanClient;
- private TitanGraph titanGraph;
+ private static final Logger log = Logger.getLogger(SimpleJanusGraphTransactionManager.class.getName());
+ private final JanusGraphClient janusGraphClient;
+ private JanusGraph janusGraph;
- public SimpleTitanTransactionManager(TitanGraphClient titanClient) {
- this.titanClient = titanClient;
+ public SimpleJanusGraphTransactionManager(JanusGraphClient janusGraphClient) {
+ this.janusGraphClient = janusGraphClient;
}
@PostConstruct
public void onInit() {
- titanGraph = titanClient.getGraph().left().on(this::onFailingToStartTitan);
+ janusGraph = janusGraphClient.getGraph().left().on(this::onFailingToStartJanusGraph);
}
@Override
public void commit(TransactionStatus transactionStatus) {
log.debug("#commit - committing transaction");
try {
- titanGraph.tx().commit();
- } catch (TitanException e) {
+ janusGraph.tx().commit();
+ } catch (JanusGraphException e) {
log.debug("#commit - failed to commit transaction", e);
throw new TransactionSystemException("failed to commit transaction", e);
}
public void rollback(TransactionStatus transactionStatus) {
log.debug("#rollback - committing transaction");
try {
- titanGraph.tx().rollback();
- } catch (TitanException e) {
+ janusGraph.tx().rollback();
+ } catch (JanusGraphException e) {
log.debug("#rollback - failed to rollback transaction", e);
throw new TransactionSystemException("failed to rollback transaction", e);
}
}
- private TitanGraph onFailingToStartTitan(TitanOperationStatus err) {
- log.debug("#onFailingToStartTitan - could not open titan client");
- throw new IllegalStateException("titan could not be initialized: " + err);
+ private JanusGraph onFailingToStartJanusGraph(JanusGraphOperationStatus err) {
+ log.debug("#onFailingToStartJanusGraph - could not open janusgraph client");
+ throw new IllegalStateException("janusgraph could not be initialized: " + err);
}
}