You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@apex.apache.org by Venky <ve...@gmail.com> on 2016/11/17 13:41:21 UTC

Fwd: Keeping the DB properties file outside the jar and connecting to database using a plain java class

Hi,

Req1: I have around 20 operators. In every operator I want to connect to
database to mark my processing as failed when there is an Io Exception or
any cluster level exception. I wanted to use plain java class here, please
let me know how we can implement it. If not suggest the better approach

Req2: I don't want the DB properties file within the application package
and wanted to maintain the DB properties outside in a properties file and
able to use them while connecting to database to fulfill my Req1. Please
let me know how we can maintain the DB properties file outside.

Req3: How can I capture cluster level exceptions like RPC Failure and etc?

-- 
Thanks & Regards
Venkatesh.

Re: Keeping the DB properties file outside the jar and connecting to database using a plain java class

Posted by Tushar Gosavi <tu...@datatorrent.com>.
Hi Venky,

For Req 2.
Can you share how do you currently load the database connection
properties in application. please share the code snippet where you are
loading connection properties. I think it could be done my copying
properties to application directory by using -files option if you are
using apex cli to launch the application. or you could read the file
from HDFS and load the properties using load(InputStream) method.


For Req 3.
You can monitor the event stream from an external process.
GET /ws/v2/applications/{appid}/events?from={fromTime}&to={toTime}&offset={offset}&limit={limit}
or
pubsub at "applications.[appid].events"

monitor for any container killed or operator stop event and then in
presence of any such event you can update database to mark the
application as failed.


Regards,
-Tushar.



On Thu, Nov 17, 2016 at 7:11 PM, Venky <ve...@gmail.com> wrote:
> Hi,
>
> Req1: I have around 20 operators. In every operator I want to connect to
> database to mark my processing as failed when there is an Io Exception or
> any cluster level exception. I wanted to use plain java class here, please
> let me know how we can implement it. If not suggest the better approach
>
> Req2: I don't want the DB properties file within the application package and
> wanted to maintain the DB properties outside in a properties file and able
> to use them while connecting to database to fulfill my Req1. Please let me
> know how we can maintain the DB properties file outside.
>
> Req3: How can I capture cluster level exceptions like RPC Failure and etc?
>
> --
> Thanks & Regards
> Venkatesh.