You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Umair Janjua <um...@gmail.com> on 2016/06/10 13:36:05 UTC

Java MongoDB Spark Stratio (Please give me a hint)

Hi my code,
When i run this program is gets stuck at
sqlContext.read().format("com.stratio.datasource.mongodb").options(options).load();
line and then it does not proceed forward. Nothing happens after that. What
should I do? How can I debug it. I am stuck here. Please any hint would be
appreciated.

-----------------------------------------------------------------------------------------
        JavaSparkContext sc = new JavaSparkContext("local[*]", "test
spark-mongodb java");
        SQLContext sqlContext = new SQLContext(sc);

        Map options = new HashMap();
        options.put("host", "host:port");
        options.put("database", "database");
        options.put("collection", "collectionName");
        options.put("credentials", "username,database,password");

        System.out.println("Check1");
        DataFrame df =
sqlContext.read().format("com.stratio.datasource.mongodb").options(options).load();

sqlContext.sql("SELECT * FROM collectionName");
        System.out.println("Check2");
        df.count();
        System.out.println("Check DataFrame Count: " + df.count());
        System.out.println("Check3");
        df.registerTempTable("collectionName");
        df.show();

-----------------------------------------------------------------------------------------

The above code only gets printed till Check1 and then it gets stuck and
nothing happens.

Cheers

Re: Java MongoDB Spark Stratio (Please give me a hint)

Posted by Umair Janjua <um...@gmail.com>.
The dataframe does not get any data. What could I be doing wrong here. I
have rechecked the credentials and other stuff. I am still trying to debug
the issue without any luck so far.

On Mon, Jun 13, 2016 at 11:30 AM, Umair Janjua <um...@gmail.com>
wrote:

> Any idea what I might be doing wrong. I am new to spark and I cannot
> proceed forward from here:
>
>
>
> -------------------------------------------------------------------
>  JavaSparkContext sc = new JavaSparkContext("local[*]", "test
> spark-mongodb java");
>         SQLContext sqlContext = new SQLContext(sc);
>
>         Map options = new HashMap();
>         options.put("host", "host:port");
>         options.put("database", "database");
>         options.put("collection", "collectionName");
>         options.put("credentials", "username,database,password");
>
>         System.out.println("Check1");
>
> DataFrame df =
> sqlContext.read().format("com.stratio.datasource.mongodb").options(options).load();
>
>         df.registerTempTable("collectionName");
>         df.show();
> ----------------------------------------------------------------------
>
> On Fri, Jun 10, 2016 at 3:36 PM, Umair Janjua <um...@gmail.com>
> wrote:
>
>> Hi my code,
>> When i run this program is gets stuck at
>> sqlContext.read().format("com.stratio.datasource.mongodb").options(options).load();
>> line and then it does not proceed forward. Nothing happens after that. What
>> should I do? How can I debug it. I am stuck here. Please any hint would be
>> appreciated.
>>
>>
>> -----------------------------------------------------------------------------------------
>>         JavaSparkContext sc = new JavaSparkContext("local[*]", "test
>> spark-mongodb java");
>>         SQLContext sqlContext = new SQLContext(sc);
>>
>>         Map options = new HashMap();
>>         options.put("host", "host:port");
>>         options.put("database", "database");
>>         options.put("collection", "collectionName");
>>         options.put("credentials", "username,database,password");
>>
>>         System.out.println("Check1");
>>         DataFrame df =
>> sqlContext.read().format("com.stratio.datasource.mongodb").options(options).load();
>>
>> sqlContext.sql("SELECT * FROM collectionName");
>>         System.out.println("Check2");
>>         df.count();
>>         System.out.println("Check DataFrame Count: " + df.count());
>>         System.out.println("Check3");
>>         df.registerTempTable("collectionName");
>>         df.show();
>>
>>
>> -----------------------------------------------------------------------------------------
>>
>> The above code only gets printed till Check1 and then it gets stuck and
>> nothing happens.
>>
>> Cheers
>>
>
>

Re: Java MongoDB Spark Stratio (Please give me a hint)

Posted by Umair Janjua <um...@gmail.com>.
Any idea what I might be doing wrong. I am new to spark and I cannot
proceed forward from here:



-------------------------------------------------------------------
 JavaSparkContext sc = new JavaSparkContext("local[*]", "test spark-mongodb
java");
        SQLContext sqlContext = new SQLContext(sc);

        Map options = new HashMap();
        options.put("host", "host:port");
        options.put("database", "database");
        options.put("collection", "collectionName");
        options.put("credentials", "username,database,password");

        System.out.println("Check1");

DataFrame df =
sqlContext.read().format("com.stratio.datasource.mongodb").options(options).load();

        df.registerTempTable("collectionName");
        df.show();
----------------------------------------------------------------------

On Fri, Jun 10, 2016 at 3:36 PM, Umair Janjua <um...@gmail.com>
wrote:

> Hi my code,
> When i run this program is gets stuck at
> sqlContext.read().format("com.stratio.datasource.mongodb").options(options).load();
> line and then it does not proceed forward. Nothing happens after that. What
> should I do? How can I debug it. I am stuck here. Please any hint would be
> appreciated.
>
>
> -----------------------------------------------------------------------------------------
>         JavaSparkContext sc = new JavaSparkContext("local[*]", "test
> spark-mongodb java");
>         SQLContext sqlContext = new SQLContext(sc);
>
>         Map options = new HashMap();
>         options.put("host", "host:port");
>         options.put("database", "database");
>         options.put("collection", "collectionName");
>         options.put("credentials", "username,database,password");
>
>         System.out.println("Check1");
>         DataFrame df =
> sqlContext.read().format("com.stratio.datasource.mongodb").options(options).load();
>
> sqlContext.sql("SELECT * FROM collectionName");
>         System.out.println("Check2");
>         df.count();
>         System.out.println("Check DataFrame Count: " + df.count());
>         System.out.println("Check3");
>         df.registerTempTable("collectionName");
>         df.show();
>
>
> -----------------------------------------------------------------------------------------
>
> The above code only gets printed till Check1 and then it gets stuck and
> nothing happens.
>
> Cheers
>