org.apache.atlas.AtlasClientV2 Java Examples

The following examples show how to use org.apache.atlas.AtlasClientV2. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BulkFetchAndUpdate.java    From atlas with Apache License 2.0 6 votes vote down vote up
private static void process(String stepToExecute, String basePath, String[] atlasEndpoint, String uid, String pwd, long fromTimestamp) throws Exception {
    AtlasClientV2 atlasClientV2 = getAtlasClientV2(atlasEndpoint, new String[]{uid, pwd});

    switch (stepToExecute) {
        case STEP_PREPARE: {
            Preparer p = new Preparer(atlasClientV2);
            p.run(basePath, fromTimestamp);
        }
        break;

        case STEP_UPDATE: {
            Updater u = new Updater(atlasClientV2);
            u.run(basePath);
        }
        break;

        default:
            printUsage();
            break;
    }
}
 
Example #2
Source File: HiveMetaStoreBridge.java    From atlas with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a HiveMetaStoreBridge.
 * @param hiveConf {@link HiveConf} for Hive component in the cluster
 */
public HiveMetaStoreBridge(Configuration atlasProperties, HiveConf hiveConf, AtlasClientV2 atlasClientV2) throws Exception {
    this.metadataNamespace          = getMetadataNamespace(atlasProperties);
    this.hiveClient                 = Hive.get(hiveConf);
    this.atlasClientV2              = atlasClientV2;
    this.convertHdfsPathToLowerCase = atlasProperties.getBoolean(HDFS_PATH_CONVERT_TO_LOWER_CASE, false);
}
 
Example #3
Source File: TestReportLineageToAtlas.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void testConnectAndReadTimeout(Map<PropertyDescriptor, String> properties, Integer expectedConnectTimeout, Integer expectedReadTimeout) throws Exception {
    // GIVEN
    reportingContext = mock(ReportingContext.class);
    when(reportingContext.getProperties()).thenReturn(properties);
    when(reportingContext.getProperty(any())).then(invocation -> new MockPropertyValue(properties.get(invocation.getArguments()[0])));

    ConfigurationContext configurationContext = new MockConfigurationContext(properties, null);

    testSubject.initialize(initializationContext);
    testSubject.setup(configurationContext);

    // WHEN
    NiFiAtlasClient niFiAtlasClient = testSubject.createNiFiAtlasClient(reportingContext);

    // THEN
    Field fieldAtlasClient = niFiAtlasClient.getClass().getDeclaredField("atlasClient");
    fieldAtlasClient.setAccessible(true);
    AtlasClientV2 atlasClient = (AtlasClientV2) fieldAtlasClient.get(niFiAtlasClient);

    Field fieldAtlasClientContext = atlasClient.getClass().getSuperclass().getDeclaredField("atlasClientContext");
    fieldAtlasClientContext.setAccessible(true);
    Object atlasClientContext = fieldAtlasClientContext.get(atlasClient);

    Method getClient = atlasClientContext.getClass().getMethod("getClient");
    getClient.setAccessible(true);
    Client jerseyClient = (Client) getClient.invoke(atlasClientContext);
    Map<String, Object> jerseyProperties = jerseyClient.getProperties();

    Integer actualConnectTimeout = (Integer) jerseyProperties.get("com.sun.jersey.client.property.connectTimeout");
    Integer actualReadTimeout = (Integer) jerseyProperties.get("com.sun.jersey.client.property.readTimeout");

    assertEquals(expectedConnectTimeout, actualConnectTimeout);
    assertEquals(expectedReadTimeout, actualReadTimeout);
}
 
Example #4
Source File: Kerberos.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasClientV2 createClient(String[] baseUrls) {
    final Configuration hadoopConf = new Configuration();
    hadoopConf.set("hadoop.security.authentication", "kerberos");
    UserGroupInformation.setConfiguration(hadoopConf);
    final UserGroupInformation ugi;
    try {
        UserGroupInformation.loginUserFromKeytab(principal, keytab);
        ugi = UserGroupInformation.getCurrentUser();
    } catch (IOException e) {
        throw new RuntimeException("Failed to login with Kerberos due to: " + e, e);
    }
    return new AtlasClientV2(ugi, null, baseUrls);
}
 
Example #5
Source File: HiveMetaStoreBridgeTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void returnExistingDatabase(String databaseName, AtlasClientV2 atlasClientV2, String metadataNamespace)
        throws AtlasServiceException {
        //getEntity(HiveDataTypes.HIVE_DB.getName(), AtlasClient.GUID, "72e06b34-9151-4023-aa9d-b82103a50e76");

    when(atlasClientV2.getEntityByAttribute(HiveDataTypes.HIVE_DB.getName(),
            Collections.singletonMap(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
                    HiveMetaStoreBridge.getDBQualifiedName(METADATA_NAMESPACE, TEST_DB_NAME))))
            .thenReturn((new AtlasEntity.AtlasEntityWithExtInfo(
                    getEntity(HiveDataTypes.HIVE_DB.getName(), AtlasClient.GUID, "72e06b34-9151-4023-aa9d-b82103a50e76"))));

}
 
Example #6
Source File: KafkaBridgeTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void returnExistingTopic(String topicName, AtlasClientV2 atlasClientV2, String clusterName)
        throws AtlasServiceException {

    when(atlasClientV2.getEntityByAttribute(KafkaDataTypes.KAFKA_TOPIC.getName(),
            Collections.singletonMap(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
                    getTopicQualifiedName(TEST_TOPIC_NAME,CLUSTER_NAME))))
            .thenReturn((new AtlasEntity.AtlasEntityWithExtInfo(
                    getTopicEntityWithGuid("0dd466a4-3838-4537-8969-6abb8b9e9185"))));

}
 
Example #7
Source File: KafkaBridge.java    From atlas with Apache License 2.0 5 votes vote down vote up
public KafkaBridge(Configuration atlasConf, AtlasClientV2 atlasClientV2) throws Exception {
    String   zookeeperConnect    = getZKConnection(atlasConf);
    int      sessionTimeOutMs    = atlasConf.getInt(ZOOKEEPER_SESSION_TIMEOUT_MS, DEFAULT_ZOOKEEPER_SESSION_TIMEOUT_MS) ;
    int      connectionTimeOutMs = atlasConf.getInt(ZOOKEEPER_CONNECTION_TIMEOUT_MS, DEFAULT_ZOOKEEPER_CONNECTION_TIMEOUT_MS);
    ZkClient zkClient            = new ZkClient(zookeeperConnect, sessionTimeOutMs, connectionTimeOutMs, ZKStringSerializer$.MODULE$);

    this.atlasClientV2     = atlasClientV2;
    this.metadataNamespace = getMetadataNamespace(atlasConf);
    this.zkUtils           = new ZkUtils(zkClient, new ZkConnection(zookeeperConnect), JaasUtils.isZkSecurityEnabled());
    this.availableTopics   = scala.collection.JavaConversions.seqAsJavaList(zkUtils.getAllTopics());
}
 
Example #8
Source File: HBaseAtlasHookIT.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AtlasClientV2 getAtlasClient() {
    AtlasClientV2 ret = null;
    if (atlasClient != null) {
        ret = atlasClient;
    }
    return ret;
}
 
Example #9
Source File: HBaseAtlasHookIT.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test (enabled = false)
public void testCreateTable() throws Exception {
    final Configuration conf = HBaseConfiguration.create();

    conf.set("hbase.zookeeper.quorum", "localhost");
    conf.set("hbase.zookeeper.property.clientPort", String.valueOf(port));
    conf.set("zookeeper.znode.parent", "/hbase-unsecure");

    Connection conn      = ConnectionFactory.createConnection(conf);
    Admin      admin     = conn.getAdmin();
    String     namespace = "test_namespace1";
    String     tablename = "test_table";

    // Create a table
    if (!admin.tableExists(TableName.valueOf(namespace, tablename))) {
        NamespaceDescriptor ns = NamespaceDescriptor.create(namespace).build();

        admin.createNamespace(ns);

        HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf(namespace, tablename));

        tableDescriptor.addFamily(new HColumnDescriptor("colfam1"));

        admin.createTable(tableDescriptor);
    }

    //assert on qualified name
    String        table       = assertTableIsRegistered(namespace, tablename);
    AtlasClientV2 atlasClient = getAtlasClient();

    if (atlasClient != null) {
        AtlasEntityWithExtInfo tableRef   = atlasClient.getEntityByGuid(table);
        String                 entityName = HBaseAtlasHook.getTableQualifiedName(CLUSTER_NAME, namespace, tablename);

        Assert.assertEquals(tableRef.getEntity().getAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME), entityName);
    } else {
        Assert.fail("Unable to create AtlasClient for Testing");
    }
}
 
Example #10
Source File: HBaseAtlasHookIT.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test (enabled = false)
public void testCreateNamesapce() throws Exception {
    final Configuration conf = HBaseConfiguration.create();

    conf.set("hbase.zookeeper.quorum", "localhost");
    conf.set("hbase.zookeeper.property.clientPort", String.valueOf(port));
    conf.set("zookeeper.znode.parent", "/hbase-unsecure");

    Connection          conn  = ConnectionFactory.createConnection(conf);
    Admin               admin = conn.getAdmin();
    NamespaceDescriptor ns    = NamespaceDescriptor.create("test_namespace").build();

    admin.createNamespace(ns);

    //assert on qualified name
    String        nameSpace   = assertNameSpaceIsRegistered(ns.getName());
    AtlasClientV2 atlasClient = getAtlasClient();

    if (atlasClient != null) {
        AtlasEntityWithExtInfo nameSpaceRef           = atlasClient.getEntityByGuid(nameSpace);
        String                 nameSpaceQualifiedName = HBaseAtlasHook.getNameSpaceQualifiedName(CLUSTER_NAME, ns.getName());

        Assert.assertEquals(nameSpaceRef.getEntity().getAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME), nameSpaceQualifiedName);
    } else {
        Assert.fail("Unable to create AtlasClient for Testing");
    }
}
 
Example #11
Source File: HBaseBridge.java    From atlas with Apache License 2.0 4 votes vote down vote up
public HBaseBridge(Configuration atlasConf, AtlasClientV2 atlasClientV2) throws Exception {
    this.atlasClientV2     = atlasClientV2;
    this.metadataNamespace = getMetadataNamespace(atlasConf);

    org.apache.hadoop.conf.Configuration conf = HBaseConfiguration.create();

    LOG.info("checking HBase availability..");

    HBaseAdmin.available(conf);

    LOG.info("HBase is available");

    Connection conn = ConnectionFactory.createConnection(conf);

    hbaseAdmin = conn.getAdmin();
}
 
Example #12
Source File: QuickStartV2.java    From atlas with Apache License 2.0 4 votes vote down vote up
QuickStartV2(String[] urls, String[] basicAuthUsernamePassword) {
    atlasClientV2 = new AtlasClientV2(urls,basicAuthUsernamePassword);
}
 
Example #13
Source File: HiveMetaStoreBridge.java    From atlas with Apache License 2.0 4 votes vote down vote up
HiveMetaStoreBridge(String metadataNamespace, Hive hiveClient, AtlasClientV2 atlasClientV2) {
    this(metadataNamespace, hiveClient, atlasClientV2, true);
}
 
Example #14
Source File: HiveMetaStoreBridge.java    From atlas with Apache License 2.0 4 votes vote down vote up
HiveMetaStoreBridge(String metadataNamespace, Hive hiveClient, AtlasClientV2 atlasClientV2, boolean convertHdfsPathToLowerCase) {
    this.metadataNamespace          = metadataNamespace;
    this.hiveClient                 = hiveClient;
    this.atlasClientV2              = atlasClientV2;
    this.convertHdfsPathToLowerCase = convertHdfsPathToLowerCase;
}
 
Example #15
Source File: QuickStartV2.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
QuickStartV2(String[] urls, String[] basicAuthUsernamePassword) {
    atlasClientV2 = new AtlasClientV2(urls,basicAuthUsernamePassword);
}
 
Example #16
Source File: QuickStartV2.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
QuickStartV2(String[] urls) throws AtlasException {
    atlasClientV2 = new AtlasClientV2(urls);
}
 
Example #17
Source File: BulkFetchAndUpdate.java    From atlas with Apache License 2.0 4 votes vote down vote up
public Preparer(AtlasClientV2 atlasClientV2) {
    this.atlasClientV2 = atlasClientV2;
}
 
Example #18
Source File: Basic.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public AtlasClientV2 createClient(String[] baseUrls) {
    return new AtlasClientV2(baseUrls, new String[]{user, password});
}
 
Example #19
Source File: NiFiAtlasClient.java    From nifi with Apache License 2.0 4 votes vote down vote up
public NiFiAtlasClient(AtlasClientV2 atlasClient) {
    this.atlasClient = atlasClient;
}
 
Example #20
Source File: QuickStartV2.java    From atlas with Apache License 2.0 4 votes vote down vote up
QuickStartV2(String[] urls) throws AtlasException {
    atlasClientV2 = new AtlasClientV2(urls);
}
 
Example #21
Source File: BulkFetchAndUpdate.java    From atlas with Apache License 2.0 2 votes vote down vote up
public Updater(AtlasClientV2 atlasClientV2) {

            this.atlasClientV2 = atlasClientV2;
        }
 
Example #22
Source File: AtlasAuthN.java    From nifi with Apache License 2.0 votes vote down vote up
AtlasClientV2 createClient(final String[] baseUrls);