Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
HBase >> mail # user >> Is "synchronized" required?


+
Bing Li 2013-02-04, 20:20
+
Harsh J 2013-02-04, 20:21
+
Ted Yu 2013-02-04, 20:25
+
Bing Li 2013-02-04, 20:32
+
Haijia Zhou 2013-02-04, 20:42
+
Adrien Mogenet 2013-02-04, 21:13
+
Nicolas Liochon 2013-02-04, 21:31
+
Bing Li 2013-02-04, 22:40
Copy link to this message
-
Re: Is "synchronized" required?
You don't have to use synchronized, just create multiple instances of
HTable and you will be fine.
Le 4 févr. 2013 23:40, "Bing Li" <[EMAIL PROTECTED]> a écrit :

> Dear Nicolas,
>
> If using synchronized is required, the performance must be too low,
> right? Are there any other ways to minimize the synchronization
> granularity?
>
> Thanks so much!
> Bing
>
> On Tue, Feb 5, 2013 at 5:31 AM, Nicolas Liochon <[EMAIL PROTECTED]> wrote:
> > Yes, HTable is not thread safe, and using synchronized around them could
> > work, but would be implementation dependent.
> > You can have one HTable per request at a reasonable cost since
> > https://issues.apache.org/jira/browse/HBASE-4805. It's seems to be
> > available in 0.92 as well.
> >
> > Cheers,
> >
> > Nicolas
> >
> >
> > On Mon, Feb 4, 2013 at 10:13 PM, Adrien Mogenet <
> [EMAIL PROTECTED]>wrote:
> >
> >> Beware, HTablePool is not totally thread-safe as well:
> >> https://issues.apache.org/jira/browse/HBASE-6651.
> >>
> >>
> >> On Mon, Feb 4, 2013 at 9:42 PM, Haijia Zhou <[EMAIL PROTECTED]> wrote:
> >>
> >> > Hi, Bing,
> >> >
> >> >  Not sure about your scenario but HTable class is not thread safe for
> >> > neither reads nor write.
> >> >  If you consider writing/reading from a table in a multiple-threaded
> way,
> >> > you can consider using HTablePool.
> >> >
> >> >  Hope it helps
> >> >
> >> > HJ
> >> >
> >> >
> >> > On Mon, Feb 4, 2013 at 3:32 PM, Bing Li <[EMAIL PROTECTED]> wrote:
> >> >
> >> > > Dear Ted and Harsh,
> >> > >
> >> > > I am sorry I didn't keep the exceptions. It occurred many days ago.
> My
> >> > > current version is 0.92.
> >> > >
> >> > > Now "synchronized" is removed. Is it correct?
> >> > >
> >> > > I will test if such exceptions are raised. I will let you know.
> >> > >
> >> > > Thanks!
> >> > >
> >> > > Best wishes,
> >> > > Bing
> >> > >
> >> > >
> >> > > On Tue, Feb 5, 2013 at 4:25 AM, Ted Yu <[EMAIL PROTECTED]> wrote:
> >> > > > Bing:
> >> > > > Use pastebin.com instead of attaching exception report.
> >> > > >
> >> > > > What version of HBase are you using ?
> >> > > >
> >> > > > Thanks
> >> > > >
> >> > > >
> >> > > > On Mon, Feb 4, 2013 at 12:21 PM, Harsh J <[EMAIL PROTECTED]>
> wrote:
> >> > > >>
> >> > > >> What exceptions do you actually receive - can you send them here?
> >> > > >> Knowing that is key to addressing your issue.
> >> > > >>
> >> > > >> On Tue, Feb 5, 2013 at 1:50 AM, Bing Li <[EMAIL PROTECTED]>
> wrote:
> >> > > >> > Dear all,
> >> > > >> >
> >> > > >> > When writing data into HBase, sometimes I got exceptions. I
> guess
> >> > they
> >> > > >> > might be caused by concurrent writings. But I am not sure.
> >> > > >> >
> >> > > >> > My question is whether it is necessary to put "synchronized"
> >> before
> >> > > >> > the writing methods? The following lines are the sample code.
> >> > > >> >
> >> > > >> > I think the directive, synchronized, must lower the
> performance of
> >> > > >> > writing. Sometimes concurrent writing is needed in my system.
> >> > > >> >
> >> > > >> > Thanks so much!
> >> > > >> >
> >> > > >> > Best wishes,
> >> > > >> > Bing
> >> > > >> >
> >> > > >> > public synchronized void AddDomainNodeRanks(String domainKey,
> int
> >> > > >> > timingScale, Map<String, Double> nodeRankMap)
> >> > > >> > {
> >> > > >> >       List<Put> puts = new ArrayList<Put>();
> >> > > >> >       Put domainKeyPut;
> >> > > >> >       Put timingScalePut;
> >> > > >> >       Put nodeKeyPut;
> >> > > >> >       Put rankPut;
> >> > > >> >
> >> > > >> >       byte[] domainNodeRankRowKey;
> >> > > >> >
> >> > > >> >       for (Map.Entry<String, Double> nodeRankEntry :
> >> > > >> > nodeRankMap.entrySet())
> >> > > >> >       {
> >> > > >> >           domainNodeRankRowKey > >> > > >> > Bytes.toBytes(RankStructure.DOMAIN_NODE_RANK_ROW +
> >> > > >> > Tools.GetAHash(domainKey + timingScale +
> nodeRankEntry.getKey()));
> >> > > >> >
> >> > > >> >          domainKeyPut = new Put(domainNodeRankRowKey);
> >> > > >> >
>  domainKeyPut.add(RankStructure.DOMAIN_NODE_RANK_FAMILY,
+
Bing Li 2013-02-05, 16:54
+
lars hofhansl 2013-02-06, 05:05
+
Bing Li 2013-02-07, 08:10
+
lars hofhansl 2013-02-07, 17:24
+
Bing Li 2013-02-06, 06:36
+
Adrien Mogenet 2013-02-06, 07:45
+
lars hofhansl 2013-02-06, 07:44
+
Bing Li 2013-02-06, 10:31
+
lars hofhansl 2013-02-06, 18:54