Return-Path: X-Original-To: apmail-spark-user-archive@minotaur.apache.org Delivered-To: apmail-spark-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D7288182E9 for ; Wed, 28 Oct 2015 06:17:44 +0000 (UTC) Received: (qmail 4873 invoked by uid 500); 28 Oct 2015 06:17:40 -0000 Delivered-To: apmail-spark-user-archive@spark.apache.org Received: (qmail 4783 invoked by uid 500); 28 Oct 2015 06:17:40 -0000 Mailing-List: contact user-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list user@spark.apache.org Received: (qmail 4773 invoked by uid 99); 28 Oct 2015 06:17:40 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Oct 2015 06:17:40 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 19EF01809D4 for ; Wed, 28 Oct 2015 06:17:40 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.979 X-Spam-Level: ** X-Spam-Status: No, score=2.979 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=databricks_com.20150623.gappssmtp.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id qz0r-A_rwFTc for ; Wed, 28 Oct 2015 06:17:39 +0000 (UTC) Received: from mail-yk0-f181.google.com (mail-yk0-f181.google.com [209.85.160.181]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id BDE8C42B60 for ; Wed, 28 Oct 2015 06:17:38 +0000 (UTC) Received: by ykdr3 with SMTP id r3so243054579ykd.1 for ; Tue, 27 Oct 2015 23:17:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=databricks_com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Hp7J04oV2dK0FzDCnmjDdiEE948YzliUG+BJhcFgTcs=; b=bVPlQden1h8OsAStfU2OykO1K0TERHfs5kGvwQVMOmRDbLrWoUOAHfd140gYs5Tjll N6ECc0WSlCNe1T826u6cPEnUVtFyfxWPK5VZY/mchpqyXhDe7Mikn/L6OCpflAsRmOs2 tFrCkw8TELrL/Vp6wzJRolaOzBJ+e2y3jtQ1P71OOuOwwepI3tvw30IScL74mExiTBC/ hJr6BL7jMUWyHDLjQ8nCa5ZzV97PZQJQJg4ve2k3eZ5l5T15nKMlDQnMfBm4KDccelFc vtmWSOI693i45KeAdCpvCQltqMLU4Yt+SqasWBFCppo/fDd+Kf57jKSoJarBUl1xbEOk o/zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=Hp7J04oV2dK0FzDCnmjDdiEE948YzliUG+BJhcFgTcs=; b=XOsnioyOQ8wdDsPh5opXaaZaseqL8pzc05z3a4tnYx7j+OqQ4jnEpFQhyrW6n47JJv 38jSe5BEGaTAGNO5Q3lUQasbQM7koTHEuPL2sqW1mFRUR095eX/7WSjB7R8qf9B+c2SV CMICbMOt8kePVjmfPc+1PKYLTrO7k8hFzeXCNj5VlcoVRfIZTrLX43V0wmLwHaITASAO lLeIeY4IU/gD5W0AkQyBcveixmpxVUxkdRLTdsdWBD+9AnpqCvK0eF/eOoXpc8HNYJ+S lnn7nO4ydtCzHjfi2RTqxSE5DOHrbW3nFgiVj0G/FFD9E1LHPme0NXXYo01t7H00eUgm PFcA== X-Gm-Message-State: ALoCoQm0Mf91d1ilVsg2yjXKz3oVbJogi+05TrtGymsCnh9P12moG33zUSl052vyajybCCKadaCB X-Received: by 10.13.213.136 with SMTP id x130mr32479681ywd.158.1446013058463; Tue, 27 Oct 2015 23:17:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.87.82 with HTTP; Tue, 27 Oct 2015 23:17:08 -0700 (PDT) In-Reply-To: References: From: Tathagata Das Date: Tue, 27 Oct 2015 23:17:08 -0700 Message-ID: Subject: Re: [Spark Streaming] Connect to Database only once at the start of Streaming job To: diplomatic Guru Cc: user Content-Type: multipart/alternative; boundary=001a114faaa4b0e66c05232426c1 --001a114faaa4b0e66c05232426c1 Content-Type: text/plain; charset=UTF-8 Yeah, of course. Just create an RDD from jdbc, call cache()/persist(), then force it to be evaluated using something like count(). Once it is cached, you can use it in a StreamingContext. Because of the cache it should not access JDBC any more. On Tue, Oct 27, 2015 at 12:04 PM, diplomatic Guru wrote: > I know it uses lazy model, which is why I was wondering. > > On 27 October 2015 at 19:02, Uthayan Suthakar > wrote: > >> Hello all, >> >> What I wanted to do is configure the spark streaming job to read the >> database using JdbcRDD and cache the results. This should occur only once >> at the start of the job. It should not make any further connection to DB >> afterwards. Is it possible to do that? >> > > --001a114faaa4b0e66c05232426c1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Yeah, of course. Just create an RDD from jdbc, call cache(= )/persist(), then force it to be evaluated using something like count(). On= ce it is cached, you can use it in a StreamingContext. Because of the cache= it should not access JDBC any more.

On Tue, Oct 27, 2015 at 12:04 PM, diplomatic Guru = <diplomaticguru@gmail.com> wrote:
I know it uses lazy model, which is why I w= as wondering.=C2=A0

On 27 October 2015 at 19:02= , Uthayan Suthakar <uthayan.suthakar@gmail.com> wro= te:
Hello all,

<= /div>
What I wanted to do is configure the spark streaming job to read = the database using JdbcRDD and cache the results. This should occur only on= ce at the start of the job. It should not make any further connection to DB= =C2=A0afterwards. Is it possible to do that?=C2=A0


--001a114faaa4b0e66c05232426c1--