Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
05eba3fd
Commit
05eba3fd
authored
4 years ago
by
Ashutosh Mestry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3907: Java Patch Handler: Set index consistency.
parent
500ea95c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
1 deletion
+99
-1
AtlasGraphManagement.java
...apache/atlas/repository/graphdb/AtlasGraphManagement.java
+5
-0
AtlasJanusGraphManagement.java
...s/repository/graphdb/janus/AtlasJanusGraphManagement.java
+36
-0
AtlasPatchManager.java
...rg/apache/atlas/repository/patches/AtlasPatchManager.java
+2
-1
IndexConsistencyPatch.java
...pache/atlas/repository/patches/IndexConsistencyPatch.java
+56
-0
No files found.
graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphManagement.java
View file @
05eba3fd
...
@@ -167,4 +167,9 @@ public interface AtlasGraphManagement {
...
@@ -167,4 +167,9 @@ public interface AtlasGraphManagement {
* @return the encoded name for the index
* @return the encoded name for the index
*/
*/
String
getIndexFieldName
(
String
indexName
,
AtlasPropertyKey
propertyKey
,
boolean
isStringField
);
String
getIndexFieldName
(
String
indexName
,
AtlasPropertyKey
propertyKey
,
boolean
isStringField
);
/**
* Set consistency to ConsistencyModifier.LOCK for all vertex and edge indexes.
*/
void
updateUniqueIndexesForConsistencyLock
();
}
}
This diff is collapsed.
Click to expand it.
graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphManagement.java
View file @
05eba3fd
...
@@ -20,6 +20,7 @@ package org.apache.atlas.repository.graphdb.janus;
...
@@ -20,6 +20,7 @@ package org.apache.atlas.repository.graphdb.janus;
import
com.google.common.base.Preconditions
;
import
com.google.common.base.Preconditions
;
import
org.apache.atlas.repository.graphdb.AtlasEdgeDirection
;
import
org.apache.atlas.repository.graphdb.AtlasEdgeDirection
;
import
org.apache.tinkerpop.gremlin.structure.Direction
;
import
org.apache.tinkerpop.gremlin.structure.Direction
;
import
org.apache.tinkerpop.gremlin.structure.Element
;
import
org.janusgraph.core.Cardinality
;
import
org.janusgraph.core.Cardinality
;
import
org.janusgraph.core.EdgeLabel
;
import
org.janusgraph.core.EdgeLabel
;
import
org.janusgraph.core.PropertyKey
;
import
org.janusgraph.core.PropertyKey
;
...
@@ -274,4 +275,38 @@ public class AtlasJanusGraphManagement implements AtlasGraphManagement {
...
@@ -274,4 +275,38 @@ public class AtlasJanusGraphManagement implements AtlasGraphManagement {
indexBuilder
.
buildCompositeIndex
();
indexBuilder
.
buildCompositeIndex
();
}
}
@Override
public
void
updateUniqueIndexesForConsistencyLock
()
{
try
{
setConsistency
(
this
.
management
,
Vertex
.
class
);
setConsistency
(
this
.
management
,
Edge
.
class
);
}
finally
{
commit
();
}
}
private
static
void
setConsistency
(
JanusGraphManagement
mgmt
,
Class
<?
extends
Element
>
elementType
)
{
LOG
.
info
(
"setConsistency: {}: Starting..."
,
elementType
.
getSimpleName
());
int
count
=
0
;
try
{
Iterable
<
JanusGraphIndex
>
iterable
=
mgmt
.
getGraphIndexes
(
elementType
);
for
(
JanusGraphIndex
index
:
iterable
)
{
if
(!
index
.
isCompositeIndex
()
||
!
index
.
isUnique
()
||
mgmt
.
getConsistency
(
index
)
==
ConsistencyModifier
.
LOCK
)
{
continue
;
}
for
(
PropertyKey
propertyKey
:
index
.
getFieldKeys
())
{
LOG
.
info
(
"setConsistency: {}: {}"
,
count
,
propertyKey
.
name
());
}
mgmt
.
setConsistency
(
index
,
ConsistencyModifier
.
LOCK
);
count
++;
}
}
finally
{
LOG
.
info
(
"setConsistency: {}: {}: Done!"
,
elementType
.
getSimpleName
(),
count
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/patches/AtlasPatchManager.java
View file @
05eba3fd
...
@@ -53,7 +53,8 @@ public class AtlasPatchManager {
...
@@ -53,7 +53,8 @@ public class AtlasPatchManager {
new
UniqueAttributePatch
(
context
),
new
UniqueAttributePatch
(
context
),
new
ClassificationTextPatch
(
context
),
new
ClassificationTextPatch
(
context
),
new
FreeTextRequestHandlerPatch
(
context
),
new
FreeTextRequestHandlerPatch
(
context
),
new
SuggestionsRequestHandlerPatch
(
context
)
new
SuggestionsRequestHandlerPatch
(
context
),
new
IndexConsistencyPatch
(
context
)
};
};
try
{
try
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/patches/IndexConsistencyPatch.java
0 → 100644
View file @
05eba3fd
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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
org
.
apache
.
atlas
.
repository
.
patches
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
static
org
.
apache
.
atlas
.
model
.
patches
.
AtlasPatch
.
PatchStatus
.
APPLIED
;
public
class
IndexConsistencyPatch
extends
AtlasPatchHandler
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
IndexConsistencyPatch
.
class
);
private
static
final
String
PATCH_ID
=
"JAVA_PATCH_0000_005"
;
private
static
final
String
PATCH_DESCRIPTION
=
"Sets index consistency for vertices and edges."
;
private
final
PatchContext
context
;
public
IndexConsistencyPatch
(
PatchContext
context
)
{
super
(
context
.
getPatchRegistry
(),
PATCH_ID
,
PATCH_DESCRIPTION
);
this
.
context
=
context
;
}
@Override
public
void
apply
()
throws
AtlasBaseException
{
AtlasGraph
graph
=
context
.
getGraph
();
try
{
LOG
.
info
(
"IndexConsistencyPatch: Starting..."
);
graph
.
getManagementSystem
().
updateUniqueIndexesForConsistencyLock
();
}
finally
{
LOG
.
info
(
"IndexConsistencyPatch: Done!"
);
}
setStatus
(
APPLIED
);
LOG
.
info
(
"IndexConsistencyPatch.apply(): patchId={}, status={}"
,
getPatchId
(),
getStatus
());
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment