seyyed / scalaris

Automatically exported from code.google.com/p/scalaris
Apache License 2.0
0 stars 0 forks source link

java-api problem #69

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I started scalaris by usising scalarisctl command, then form JVM I tried to 
make some requests to the dht by using Java-api 
2. Once instantiated the Scalaris object:

   de.zib.scalaris.Scalaris sc = new de.zib.scalaris.Scalaris(de.zib.scalaris.Connection conn) 

   I'm trying to do: 
   sc.read(key) and i get this error:
    de.zib.scalaris.UnknownException: com.ericsson.otp.erlang.OtpErlangAtom cannot be cast to com.ericsson.otp.erlang.OtpErlangString

What is the expected output? the Value of the associated key, or null if the 
key doesn' exist  
What do you see instead?
de.zib.scalaris.UnknownException: com.ericsson.otp.erlang.OtpErlangAtom cannot 
be cast to com.ericsson.otp.erlang.OtpErlangString

What version of the product are you using? latest version from the trunk, 
Scalaris.class is 2.2 version
 On what operating system?
Linux Ubuntu: 2.6.31-22-generic

Please provide any additional information below.

Original issue reported on code.google.com by susanna....@gmail.com on 15 Nov 2010 at 4:22

GoogleCodeExporter commented 8 years ago
Did you store the value using the Java-API? Did you store any value at all in 
the Scalaris ring?

Can you provide the whole stacktrace that comes with the exception?

Original comment by nico.kru...@googlemail.com on 15 Nov 2010 at 4:35

GoogleCodeExporter commented 8 years ago
stack trace for this exception is empty, i mean e.printStackTrace() return 
null. However this is the method that raises the exception:

public String read(String key) throws ConnectionException,
    TimeoutException, UnknownException, NotFoundException {
    try {
        CustomOtpStringObject result = new CustomOtpStringObject();
        readCustom(key, result);
        return result.getValue(); <--- THIS CAUSES EXCEPTION
//      return ((OtpErlangString) readObject(new OtpErlangString(key)))
//                  .stringValue();
        } catch (ClassCastException e) {
            // e.printStackTrace();
            throw new UnknownException(e);
        }
    }

Original comment by susanna....@gmail.com on 15 Nov 2010 at 4:48

GoogleCodeExporter commented 8 years ago
ERROR scalaris.ScalarisHLObject [getValues:67] 
eu.xtreemos.ads.exceptions.DhtException: de.zib.scalaris.UnknownException: 
com.ericsson.otp.erlang.OtpErlangAtom cannot be cast to 
com.ericsson.otp.erlang.OtpErlangString
de.zib.scalaris.UnknownException: com.ericsson.otp.erlang.OtpErlangAtom cannot 
be cast to com.ericsson.otp.erlang.OtpErlangString
    at de.zib.scalaris.CustomOtpStringObject.convertFromOtpObject(CustomOtpStringObject.java:75)
    at de.zib.scalaris.CustomOtpObject.getValue(CustomOtpObject.java:81)
    at de.zib.scalaris.Scalaris.read(Scalaris.java:321)

Original comment by susanna....@gmail.com on 15 Nov 2010 at 4:51

GoogleCodeExporter commented 8 years ago
Did you try to read a value that you have previously written using erlang, the 
web debug interface or the JSON API? This is currently unsupported and may 
result in such an exception if the types don't match.

Otherwise you could try to print result.getOtpValue() to see what's behind the 
received object.

Original comment by nico.kru...@googlemail.com on 15 Nov 2010 at 5:11

GoogleCodeExporter commented 8 years ago
Actually I tried to test if a value is already stored into the dht. I suppose 
that the read method should return a "null" value if the key doesn't exist. I 
cannot modify the method read cause is in the scalaris.jar package and we use 
it as external library. Is there a way to check if a value is already stored or 
not?
Thanks

Original comment by susanna....@gmail.com on 15 Nov 2010 at 9:53

GoogleCodeExporter commented 8 years ago
I'm see ing now that there is another method called readObject(new 
OptErlangString( key ) ) that belongs to the class Scalaris, should I use this 
instead of the normal read method to avoid this exception?

Original comment by susanna....@gmail.com on 15 Nov 2010 at 10:31

GoogleCodeExporter commented 8 years ago
yes, you could use the readObject methodfor that since it is not doing any 
conversion.
If you want the value behind, you'd need to convert it yourself though.

If the key doesn't exist, a NotFoundException will be thrown (as documented). 
There's no other way of checking whether a key exists. You can implement a 
wrapper method using readObject if you'd like to have such a function.

Original comment by nico.kru...@googlemail.com on 16 Nov 2010 at 8:10

GoogleCodeExporter commented 8 years ago
I've changed the call by using:
Scalaris sc = new scalaris(connection);
...
OtpErlangAtom results=  (OtpErlangAtom) sc.readObject(new OtpErlangString(key));
the results variable contains "badrpc" value.
However I tried to make a test: before to try to read the key I tried to insert 
it in this way:

sc.writeObject(new OtpErlangString(key), new OtpErlangString("mytest"));
OtpErlangAtom results=  (OtpErlangAtom) sc.readObject(new OtpErlangString(key));

In this case the the writeObject call raises this exception:
de.zib.scalaris.UnknownException: Erlang message: 
{badrpc,{'EXIT',{undef,[{transaction_api,single_write,["4SERVVO","mytest"]},{rpc
,'-handle_call/3-fun-0-',5}]}}}

any ideas?

Original comment by susanna....@gmail.com on 16 Nov 2010 at 3:41

GoogleCodeExporter commented 8 years ago
looks like the compilation was not (fully) successful and at least the 
transaction_api module was not compiled, i.e. transaction_api.beam is not in 
the ebin folder. Try a
> make
in the scalaris folder and look out for errors. If everything is fine, please 
test using the "scalaris" client in the java-api folder first to check for 
basic operation, e.g.
> ./scalaris --noconfig -w foo bar

Original comment by nico.kru...@googlemail.com on 16 Nov 2010 at 4:08

GoogleCodeExporter commented 8 years ago
reinstalled by typing:
./config
make
sudo make install
However command "scalarisctl boot start" seems to start proberly but when I try 
to make ./scalaris --noconfig -w foo bar I receive:
write failed with unknown: Erlang message: 
{badrpc,{'EXIT',{function_clause,[{random,uniform,""},{'transstore.transaction_a
pi',do_transaction,3},{rpc,'-handle_call/3-fun-0-',5}]}}}

How should I start a boot node? 

Original comment by susanna....@gmail.com on 16 Nov 2010 at 5:20

GoogleCodeExporter commented 8 years ago
Looks maybe like the "make install" is missing some files.

Could you try doing everything inside the build dir, e.g.
./configure
make
./bin/scalarisctl -d boot start
./java-api/scalaris --noconfig -w foo bar

If this doesn't work either, please attach the log of all these steps, e.g. by 
redirecting them to a file, as well as the list of files in the ebin directory 
and the logs inside ./log/boot - hopefully something in there will then direct 
us into the right direction.

Original comment by nico.kru...@googlemail.com on 17 Nov 2010 at 6:50

GoogleCodeExporter commented 8 years ago
- Please make sure that you use an R13B0X or R14BXX version of Erlang. We will 
add a version check to the configure script.

- Please use the current OtpErlang-*.jar in your service. Currently it is 
OtpErlang-1.5.3.1.jar.

- Is it possible that you copied *.beam files or the complete Scalaris build 
from one machine to the other? You said that you are using R12B04 on brunello, 
however Scalaris does not compile with R12B04.

Original comment by schu...@gmail.com on 18 Nov 2010 at 9:13

GoogleCodeExporter commented 8 years ago
Another idea:

Is it possible that you are mixing the old 0.2.x Scalaris release for XtreemOS 
with a scalaris.jar from the svn repository? You are getting error messages 
saying e.g. that the function txlog:new() is unknown on the Scalaris side:
{badrpc*,{'EXIT',{undef,[{txlog,new,[]},{rpc,'-handle_call_call/6-fun-0-',5}]}}}
In the 0.2.x release there was no txlog:now() but a transstore.txlog:new().

You should consider using one of the prebuild rpms, see 
http://code.google.com/p/scalaris/wiki/FAQ#Prebuild_packages.

Original comment by schu...@gmail.com on 18 Nov 2010 at 9:34

GoogleCodeExporter commented 8 years ago
Basically i've tested my servirce on two different machines:
the first one is an Xtreemos machine 3.0 with erlang 5.6.4 and scalaris 
installed through rpm repository so it should be ok. 
The second one is a guest machine on VirtualBox that has Ubuntu 10.04 and i've 
installed scalaris from repository that regards ubuntu in the page you linked. 
erlang version is 5.7.4
However on xtreemos machine when i try to make a Write operation i get this 
error: 

de.zib.scalaris.UnknownException: Erlang message: 
{badrpc,{'EXIT',{undef,[{transaction_api,single_write,["4SERVVO","test"]},{rpc,'
-handle_call/3-fun-0-',5}]}}}
    at de.zib.scalaris.Scalaris.writeObject(Scalaris.java:413)

I'm on skype, i've mailed to you my skype account :)
thanks 

Original comment by susanna....@gmail.com on 18 Nov 2010 at 11:04

GoogleCodeExporter commented 8 years ago
I guess you are using the same scalaris.jar in both cases. This won't work.

For the xtreemos machine you have to link srds with the scalaris.jar which was 
installed by the xtreemos rpm.

For the ubuntu machine you have to link srds with the scalaris.jar which was 
installed by the ubuntu package.

Original comment by schu...@gmail.com on 18 Nov 2010 at 11:21

GoogleCodeExporter commented 8 years ago
however on brunello i have this erlang version:
Erlang (BEAM) emulator version 5.6.4 [source] [async-threads:0] [hipe] 
[kernel-poll:false]
Eshell V5.6.4  (abort with ^G)
1> init:script_id(). 
{"OTP  APN 181 01","R12B"}

and both scalaris and erlang are downloaded fro Xtreemos3.0 repositories:
http://ftp-stud.hs-esslingen.de/Mirrors/Mandrivalinux/devel/xtreemos/3.0/i586/me
dia/main/release/
here you can find erlang packages (R12B4) and scalaris package 0.2.3

Original comment by susanna....@gmail.com on 18 Nov 2010 at 11:28

GoogleCodeExporter commented 8 years ago
Right, on brunello you are using the "official xtreemos Scalaris". And when you 
run srds on this node, you have to link srds with the scalaris.jar from the 
xtreemos rpm.

I believe that you are using a different scalaris on the ubuntu machine. You 
downloaded scalaris from here:
http://download.opensuse.org/repositories/home:/tschuett/xUbuntu_10.10/
This package comes with a different scalaris.jar. You have to match the 
scalaris.jar with the resp. scalaris installation. Otherwise you get these 
badrpc messages.

Original comment by schu...@gmail.com on 18 Nov 2010 at 12:10

GoogleCodeExporter commented 8 years ago
Yes, that's the error, thanks for help, now it works

Original comment by susanna....@gmail.com on 18 Nov 2010 at 12:32

GoogleCodeExporter commented 8 years ago

Original comment by schu...@gmail.com on 18 Nov 2010 at 1:43

GoogleCodeExporter commented 8 years ago
I'm facing with another problem now.
Your methods read and write seems to have problem regarding casting like this:
de.zib.scalaris.UnknownException: com.ericsson.otp.erlang.OtpErlangAtom cannot 
be cast to com.ericsson.otp.erlang.OtpErlangString
So I used readObject, but in this case i get an error in my code when I try to 
get serialize data your methods returned. In particular:
Java.io.StramCorruptedException: invalid stream header this because seems that 
the object has already been read by another stream. Does readObject method use 
object serialization with streams?  

Original comment by susanna....@gmail.com on 19 Nov 2010 at 12:35

GoogleCodeExporter commented 8 years ago
Our implementation of readObject simply uses the objects returned by JInterface 
- I don't know about their use of streams or serialization capabilities. Please 
refer to the JInterface documentation if you want to find out more about it. 
Depending on your application's needs, you can of course convert it to 
something useful, e.g. Strings, yourself.

Note that read and write are both intended to read and write Strings only and 
therefor fail with anything else (as expected). For all other purposes, 
read/writeObject and read/writeCustom can be used. Refer to the 
CustomOtpFastStringObject and FastStringBenchmark example for the latter.

Also note that this is probably better discussed on our mailing list
http://groups.google.com/group/scalaris/
rather than in an issue tracker. Additionally this issue's problem has already 
been solved and should thus not be hijacked for anything else.

Original comment by nico.kru...@googlemail.com on 19 Nov 2010 at 1:44