Search in sources :

Example 41 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-aai-common by onap.

the class RelationshipGremlinQueryTest method setup.

@Before
public void setup() {
    version = new SchemaVersion("v10");
    dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 42 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-aai-common by onap.

the class RelationshipQueryTest method setup.

@Before
public void setup() {
    version = new SchemaVersion("v10");
    dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 43 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-aai-common by onap.

the class UniqueRelationshipQueryTest method setup.

/**
 * Setup.
 *
 * @throws JAXBException the JAXB exception
 */
@Before
public void setup() throws JAXBException {
    version = new SchemaVersion("v10");
    dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_UNIQUE, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
    unmarshaller = context.createUnmarshaller();
    unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
    unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 44 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-aai-common by onap.

the class UniqueURIQueryTest method parentQuery.

/**
 * Parent query.
 *
 * @throws UnsupportedEncodingException the unsupported encoding exception
 * @throws AAIException the AAI exception
 */
@Test
public void parentQuery() throws UnsupportedEncodingException, AAIException {
    version = new SchemaVersion("v10");
    dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_UNIQUE, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
    URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1").build();
    String key = "complex/key1";
    QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
    GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key);
    String parentResultType = "";
    String resultType = "complex";
    String containerType = "";
    testSet(query, expected, expected, parentResultType, resultType, containerType);
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SchemaVersion(org.onap.aai.setup.SchemaVersion) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) URI(java.net.URI) Test(org.junit.Test)

Example 45 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-aai-common by onap.

the class AbstractGraphTraversalBuilderOptmizationTest method setupData.

protected void setupData(int tenantNum, int vserverPerTenantNum, String prefix) throws Exception {
    loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
    graph = AAIGraph.getInstance().getGraph();
    dbEngine = new JanusGraphDBEngine(queryStyle, loader);
    g = dbEngine.startTransaction().traversal();
    dbser = new DBSerializer(schemaVersions.getDefaultVersion(), dbEngine, introspectorFactoryType, "AAI-TEST-" + prefix);
    rand = new Random();
    Vertex cr;
    Vertex tenant;
    Vertex vserver;
    String crUri;
    String tenantUri;
    String vserverUri;
    System.out.println("Data load started");
    long startTime = System.currentTimeMillis();
    for (int crCtr = 0; crCtr < 3; crCtr++) {
        crUri = String.format(crUriPattern, prefix + "cloud-owner-" + crCtr, prefix + "cloud-region-id-" + crCtr);
        // System.out.println(crUri);
        cr = g.addV(CLOUD_REGION).property(AAIProperties.NODE_TYPE, CLOUD_REGION).property(CLOUD_REGION_ID, prefix + "cloud-region-id-" + crCtr).property(CLOUD_OWNER, prefix + "cloud-owner-" + crCtr).property(AAIProperties.AAI_URI, crUri).next();
        for (int i = 0; i < tenantNum; i++) {
            Introspector intro = loader.introspectorFromName(TENANT);
            tenant = dbser.createNewVertex(intro);
            edgeSer.addTreeEdge(g, cr, tenant);
            intro.setValue(TENANT_ID, prefix + "tenant-id-" + i);
            intro.setValue(TENANT_NAME, prefix + "tenant-name-" + i);
            dbser.serializeSingleVertex(tenant, intro, "AAI-TEST-" + prefix);
            // System.out.println("Tenant " + crCtr + " " + i);
            for (int j = 0; j < vserverPerTenantNum; j++) {
                intro = loader.introspectorFromName(VSERVER);
                vserver = dbser.createNewVertex(intro);
                edgeSer.addTreeEdge(g, tenant, vserver);
                intro.setValue(VSERVER_ID, prefix + "vserver-id-" + i + "-" + j);
                intro.setValue(VSERVER_NAME, prefix + "vserver-name-" + i + "-" + j);
                intro.setValue(PROV_STATUS, RANDOM_VALUES.get(rand.nextInt(RANDOM_VALUES.size())));
                intro.setValue(VSERVER_SELFLINK, RANDOM_VALUES.get(rand.nextInt(RANDOM_VALUES.size())));
                dbser.serializeSingleVertex(vserver, intro, "AAI-TEST-" + prefix);
            // System.out.println("Vserver " + crCtr + " " + i + " " + j);
            }
        }
    }
    // g.V().forEachRemaining(v -> v.properties().forEachRemaining(p -> System.out.println(p.key() + " : " +
    // p.value())));
    // g.E().forEachRemaining(e -> System.out.println(e.outVertex().property(AAIProperties.NODE_TYPE).value() + " :
    // " + e.inVertex().property(AAIProperties.NODE_TYPE).value()));
    long time = System.currentTimeMillis() - startTime;
    System.out.println("Data load ended\n" + time);
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) DBSerializer(org.onap.aai.serialization.db.DBSerializer) Random(java.util.Random) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Introspector(org.onap.aai.introspection.Introspector)

Aggregations

JanusGraphDBEngine (org.onap.aai.serialization.engines.JanusGraphDBEngine)78 TransactionalGraphEngine (org.onap.aai.serialization.engines.TransactionalGraphEngine)51 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)45 Before (org.junit.Before)40 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)27 DBSerializer (org.onap.aai.serialization.db.DBSerializer)10 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)8 SchemaVersion (org.onap.aai.setup.SchemaVersion)8 Loader (org.onap.aai.introspection.Loader)7 AAIException (org.onap.aai.exceptions.AAIException)5 ModelType (org.onap.aai.introspection.ModelType)3 QueryStyle (org.onap.aai.serialization.engines.QueryStyle)3 UrlBuilder (org.onap.aai.serialization.queryformats.utils.UrlBuilder)3 Properties (java.util.Properties)2 Test (org.junit.Test)2 NotificationHelper (org.onap.aai.migration.NotificationHelper)2 UEBNotification (org.onap.aai.rest.ueb.UEBNotification)2 JCommander (com.beust.jcommander.JCommander)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URI (java.net.URI)1