Commit 8dc4041c by Sarath Subramanian

ATLAS-3104: Fix stale transaction alerts in atlas logs

parent a9fc73a4
......@@ -208,6 +208,11 @@ public interface AtlasGraph<V, E> {
void clear();
/**
* Gets all open transactions.
*/
Set getOpenTransactions();
/**
* Converts the graph to gson and writes it to the specified stream.
*
* @param os
......
......@@ -60,6 +60,7 @@ import org.janusgraph.core.SchemaViolationException;
import org.janusgraph.core.schema.JanusGraphIndex;
import org.janusgraph.core.schema.JanusGraphManagement;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.graphdb.database.StandardJanusGraph;
import javax.script.Bindings;
import javax.script.ScriptEngine;
......@@ -87,6 +88,7 @@ public class AtlasJanusGraph implements AtlasGraph<AtlasJanusVertex, AtlasJanusE
private final ConvertGremlinValueFunction GREMLIN_VALUE_CONVERSION_FUNCTION = new ConvertGremlinValueFunction();
private final Set<String> multiProperties = new HashSet<>();
private final StandardJanusGraph janusGraph;
public AtlasJanusGraph() {
//determine multi-properties once at startup
......@@ -107,6 +109,8 @@ public class AtlasJanusGraph implements AtlasGraph<AtlasJanusVertex, AtlasJanusE
mgmt.rollback();
}
}
janusGraph = (StandardJanusGraph) AtlasJanusGraphDatabase.getGraphInstance();
}
@Override
......@@ -217,6 +221,11 @@ public class AtlasJanusGraph implements AtlasGraph<AtlasJanusVertex, AtlasJanusE
}
@Override
public Set getOpenTransactions() {
return janusGraph.getOpenTransactions();
}
@Override
public void shutdown() {
getGraph().close();
}
......
......@@ -84,10 +84,10 @@ public abstract class AtlasJavaPatchHandler {
setEncodedProperty(patchVertex, CREATED_BY_KEY, getCurrentUser());
setEncodedProperty(patchVertex, MODIFIED_BY_KEY, getCurrentUser());
graph.commit();
addToPatchesRegistry(patchId, getPatchStatus());
}
graph.commit();
}
private PatchStatus getPatchStatus(Map<String, PatchStatus> patchesRegistry) {
......@@ -108,10 +108,10 @@ public abstract class AtlasJavaPatchHandler {
setEncodedProperty(patchVertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
setEncodedProperty(patchVertex, MODIFIED_BY_KEY, getCurrentUser());
graph.commit();
addToPatchesRegistry(getPatchId(), getPatchStatus());
}
graph.commit();
}
public PatchStatus getPatchStatus() {
......
......@@ -136,7 +136,6 @@ public class UniqueAttributePatchHandler extends AtlasJavaPatchHandler {
private void registerUniqueAttrPropertyKeys(Collection<AtlasAttribute> attributes) throws IndexException {
AtlasGraphManagement management = graph.getManagementSystem();
boolean idxCreated = false;
for (AtlasAttribute attribute : attributes) {
String uniquePropertyName = attribute.getVertexUniquePropertyName();
......@@ -150,14 +149,11 @@ public class UniqueAttributePatchHandler extends AtlasJavaPatchHandler {
AtlasCardinality cardinality = indexer.toAtlasCardinality(attributeDef.getCardinality());
indexer.createVertexIndex(management, uniquePropertyName, UniqueKind.NONE, propertyClass, cardinality, isIndexable, true);
idxCreated = true;
}
}
//Commit indexes
if (idxCreated) {
indexer.commit(management);
}
indexer.commit(management);
graph.commit();
}
}
\ No newline at end of file
......@@ -512,9 +512,17 @@ public class AtlasGraphUtilsV2 {
LOG.warn("getPatches() returned empty result!");
}
getGraphInstance().commit();
return new AtlasPatches(ret);
}
public int getOpenTransactions() {
Set openTransactions = getGraphInstance().getOpenTransactions();
return (openTransactions != null) ? openTransactions.size() : 0;
}
private static AtlasPatch toAtlasPatch(AtlasVertex vertex) {
AtlasPatch ret = new AtlasPatch();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment