* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.sparky.viewandinspect.services;
+package org.onap.aai.sparky.viewandinspect.context;
import static java.util.concurrent.CompletableFuture.supplyAsync;
import org.onap.aai.sparky.logging.AaiUiMsgs;
import org.onap.aai.sparky.sync.entity.SearchableEntity;
import org.onap.aai.sparky.util.NodeUtils;
+import org.onap.aai.sparky.viewandinspect.VisualizationContext;
import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
import org.onap.aai.sparky.viewandinspect.entity.ActiveInventoryNode;
-import org.onap.aai.sparky.viewandinspect.entity.InlineMessage;
import org.onap.aai.sparky.viewandinspect.entity.NodeProcessingTransaction;
import org.onap.aai.sparky.viewandinspect.entity.QueryParams;
import org.onap.aai.sparky.viewandinspect.entity.Relationship;
*/
public class BaseVisualizationContext implements VisualizationContext {
- private static final int MAX_DEPTH_EVALUATION_ATTEMPTS = 100;
- private static final String DEPTH_ALL_MODIFIER = "?depth=all";
- private static final String NODES_ONLY_MODIFIER = "?nodes-only";
- private static final String SERVICE_INSTANCE = "service-instance";
+ protected static final int MAX_DEPTH_EVALUATION_ATTEMPTS = 100;
+ protected static final String DEPTH_ALL_MODIFIER = "?depth=all";
+ protected static final String NODES_ONLY_MODIFIER = "?nodes-only";
+ protected static final String SERVICE_INSTANCE = "service-instance";
private static final Logger LOG = LoggerFactory.getInstance().getLogger(
BaseVisualizationContext.class);
- private final ActiveInventoryAdapter aaiAdapter;
-
- private int maxSelfLinkTraversalDepth;
- private AtomicInteger numLinksDiscovered;
- private AtomicInteger numSuccessfulLinkResolveFromCache;
- private AtomicInteger numSuccessfulLinkResolveFromFromServer;
- private AtomicInteger numFailedLinkResolve;
- private AtomicInteger aaiWorkOnHand;
+ protected final ActiveInventoryAdapter aaiAdapter;
+
+ protected int maxSelfLinkTraversalDepth;
+ protected AtomicInteger numLinksDiscovered;
+ protected AtomicInteger numSuccessfulLinkResolveFromCache;
+ protected AtomicInteger numSuccessfulLinkResolveFromFromServer;
+ protected AtomicInteger numFailedLinkResolve;
+ protected AtomicInteger aaiWorkOnHand;
- private VisualizationConfigs visualizationConfigs;
+ protected VisualizationConfigs visualizationConfigs;
- private AtomicInteger totalLinksRetrieved;
+ protected AtomicInteger totalLinksRetrieved;
- private final long contextId;
- private final String contextIdStr;
+ protected final long contextId;
+ protected final String contextIdStr;
- private ObjectMapper mapper;
- private InlineMessage inlineMessage = null;
+ protected ObjectMapper mapper;
- private ExecutorService aaiExecutorService;
- private OxmEntityLookup oxmEntityLookup;
- private boolean rootNodeFound;
+ protected ExecutorService aaiExecutorService;
+ protected OxmEntityLookup oxmEntityLookup;
+ protected boolean rootNodeFound;
/*
* The node cache is intended to be a flat structure indexed by a primary key to avoid needlessly
* re-requesting the same self-links over-and-over again, to speed up the overall render time and
* more importantly to reduce the network cost of determining information we already have.
*/
- private ConcurrentHashMap<String, ActiveInventoryNode> nodeCache;
+ protected ConcurrentHashMap<String, ActiveInventoryNode> nodeCache;
/**
* Instantiates a new self link node collector.
*
* @param nodeId the node id
*/
- private void processSelfLinkResponse(String nodeId) {
+ protected void processSelfLinkResponse(String nodeId) {
if (nodeId == null) {
LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR, "Cannot process self link"
}
- private void handleNodeValue(ActiveInventoryNode ain, String fieldName, String key, String value) {
+ protected void handleNodeValue(ActiveInventoryNode ain, String fieldName, String key, String value) {
if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
/*
*
* @param nodeId the node id
*/
- private void performSelfLinkResolve(String nodeId) {
+ protected void performSelfLinkResolve(String nodeId) {
if (nodeId == null) {
LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR, "Resolve of self-link"
*
* @param nodeId the node id
*/
- private void processNeighbors(String nodeId) {
+ protected void processNeighbors(String nodeId) {
if (nodeId == null) {
LOG.error(AaiUiMsgs.SELF_LINK_PROCESS_NEIGHBORS_ERROR, "Failed to process"
* @param queryParams the query params
* @return true, if successful
*/
- private void findAndMarkRootNode(QueryParams queryParams) {
+ protected void findAndMarkRootNode(QueryParams queryParams) {
if (isRootNodeFound()) {
return;
* Process current node states.
*
*/
- private void processCurrentNodeStates(QueryParams queryParams) {
+ protected void processCurrentNodeStates(QueryParams queryParams) {
/*
* Force an evaluation of node depths before determining if we should limit state-based
* traversal or processing.
* @param attributeGroup the attribute group
* @return true, if successful
*/
- private boolean addComplexGroupToNode(ActiveInventoryNode targetNode, JsonNode attributeGroup) {
+ protected boolean addComplexGroupToNode(ActiveInventoryNode targetNode, JsonNode attributeGroup) {
if (attributeGroup == null) {
targetNode.changeState(NodeProcessingState.ERROR,
return numFailedLinkResolve.get();
}
- public InlineMessage getInlineMessage() {
- return inlineMessage;
- }
-
- public void setInlineMessage(InlineMessage inlineMessage) {
- this.inlineMessage = inlineMessage;
- }
-
public void setMaxSelfLinkTraversalDepth(int depth) {
this.maxSelfLinkTraversalDepth = depth;
}
* @param pkeyNames the pkey names
* @return the relationship primary key values
*/
- private String getRelationshipPrimaryKeyValues(Relationship r, String entityType,
+ protected String getRelationshipPrimaryKeyValues(Relationship r, String entityType,
List<String> pkeyNames) {
StringBuilder sb = new StringBuilder(64);
* @param keyName the key name
* @return the string
*/
- private String extractKeyValueFromRelationData(Relationship r, String keyName) {
+ protected String extractKeyValueFromRelationData(Relationship r, String keyName) {
RelationshipData[] rdList = r.getRelationshipData();
* @param ain the ain
* @return true, if successful
*/
- private boolean addNodeQueryParams(ActiveInventoryNode ain) {
+ protected boolean addNodeQueryParams(ActiveInventoryNode ain) {
if (ain == null) {
LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE_NODE_ID, "ActiveInventoryNode is null");
* @param relationshipList the relationship list
* @return true, if successful
*/
- private boolean addSelfLinkRelationshipChildren(ActiveInventoryNode processingNode,
+ protected boolean addSelfLinkRelationshipChildren(ActiveInventoryNode processingNode,
RelationshipList relationshipList) {
if (relationshipList == null) {
Relationship[] relationshipArray = relationshipList.getRelationshipList();
OxmEntityDescriptor descriptor = null;
- String repairedSelfLink = null;
if (relationshipArray != null) {
*
* @param nodeId the node id
*/
- private void processInitialState(String nodeId) {
+ protected void processInitialState(String nodeId) {
if (nodeId == null) {
LOG.error(AaiUiMsgs.FAILED_TO_PROCESS_INITIAL_STATE, "Node id is null");
* @param skeletonNode the skeleton node
* @param queryParams the query params
*/
- private void processSearchableEntity(SearchableEntity searchTargetEntity, QueryParams queryParams) {
+ protected void processSearchableEntity(SearchableEntity searchTargetEntity, QueryParams queryParams) {
if (searchTargetEntity == null) {
return;
nodeCache.putIfAbsent(newNode.getNodeId(), newNode);
}
- private int getTotalWorkOnHand() {
+ protected int getTotalWorkOnHand() {
int numNodesWithPendingStates = 0;
*
* @return true, if successful
*/
- private void processOutstandingWork(QueryParams queryParams) {
+ protected void processOutstandingWork(QueryParams queryParams) {
while (getTotalWorkOnHand() > 0) {
/**
* Verify outbound neighbors.
*/
- private void verifyOutboundNeighbors() {
+ protected void verifyOutboundNeighbors() {
for (ActiveInventoryNode srcNode : nodeCache.values()) {
/**
* Evaluate node depths.
*/
- private void evaluateNodeDepths() {
+ protected void evaluateNodeDepths() {
int numChanged = -1;
int numAttempts = 0;
*/
- private String getEntityTypePrimaryKeyName(String entityType) {
+ protected String getEntityTypePrimaryKeyName(String entityType) {
if (entityType == null) {
LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE, "node primary key"