Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 01-29-2007
jdekozak jdekozak is offline
Registered User
 
Name: Julien de KOZAK
Organization: TSoftware
Project: TSoftwareSCADA
 
Join Date: Jan 2007
Location: Paris, FRANCE
Posts: 2
Freeze evictor synchronization with Java tie classes

Hi,

First, congratulations!! ICE is really a great software!! Simple and powerful!!

Then my problem (certainly more a misunderstanding than a real bug...):

I've read the documentation about the Freeze evictor and I need some details about its synchronization.

I plan to use the tie classes to separate persistence data from interface implementation. On top of that, I also need implementation inheritance rather than interface inheritance.
The Ice manual highlights the concurrency issue between the Freeze saving thread and the servant implementation, the solution consists in synchronizing the servant. But with the tie classes, this code is generated and I don't want to specialize the tie classes only to put the "synchronized" keyword. I've got a lot of functions and a lot of classes, and this job would be fastidious.

So I'm wondering how to perform synchronization in a simple manner. My idea is that it would be useful to put an option on the slice2java command line.

Any advice would be welcome!

As examples are always clearer to understand, here is the sample of code:
(I know that if I put the keyword "nonmutating" here, it would be OK, but I've got other functions that really modify the servant tie class, it's only an example, not the real code...)

Root.ice
module Inter {
interface Root {
int getID();
};
};

Entity.ice
module Inter {
interface Entity extends Root {
int getClassID();
};
};

RootClass.ice
module InterPersis {
class RootClass implements Inter::Root {
int ID;
};
};

EntityClass.ice
module InterPersis {
class EntityClass extends RootClass implements Inter::Entity {
int ClassID;
};
};

RootImpl.java
public class RootImpl extends _RootClassTie {
public RootImpl() {
super();
ice_delegate(new RootBehavior(this));
}
}

EntityImpl.java
public class EntityImpl extends _EntityClassTie {
public EntityImpl() {
super();
ice_delegate(new EntityBehavior(this));
}
}

RootBehavior.java
public class RootBehavior implements _RootOperations {
private RootClass attributes;
public RootBehavior(RootClass attr) {
attributes = attr;
}
public int getID(Current __current) {
return attributes.ID;
}
}

EntityBehavior.java
public class EntityBehavior extends RootBehavior implements _EntityOperations {
private EntityClass attributes;
public EntityBehavior(EntityClass attr) {
super(attr);
attributes = attr;
}
public int getClassID(Current __current) {
return attributes.ClassID;
}
}

Bye
__________________
Julien
Reply With Quote
  #2 (permalink)  
Old 01-30-2007
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,564
Hi Julien,

You don't need to specialize the tie class to add synchronization. You can just synchronize on the tie object from the delegate implementation, like the following for example:

public int getClassID(Current __current)
{
synchronized(attributes)
{
return attributes.ClassID;
}
}

This synchronization will prevent the Freeze evictor saving thread from reading the "attributes" servant concurrently.

Cheers,
Benoit.
Reply With Quote
  #3 (permalink)  
Old 01-30-2007
jdekozak jdekozak is offline
Registered User
 
Name: Julien de KOZAK
Organization: TSoftware
Project: TSoftwareSCADA
 
Join Date: Jan 2007
Location: Paris, FRANCE
Posts: 2
Hi Benoit,

I realize that my question was a bit silly! I've never wrote a single line of Java code, only C++, and I didn't know this syntax for the synchronized keyword.

So, I really thank you for the reply and apologize for the wasted time.

Bye
__________________
Julien
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Slow in Freeze Evictor add operation Yunqiao Yin Help Center 2 02-06-2007 08:38 PM
Freeze Evictor Transactions acbell Help Center 2 12-19-2005 12:43 PM
Identity Map for Freeze Evictor acbell Help Center 4 09-01-2005 04:27 PM
Fast track Freeze evictor for RDBMS StuartA Comments 0 05-23-2005 05:56 AM
evictor question xdm Help Center 1 09-14-2003 02:11 AM


All times are GMT -4. The time now is 12:56 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.