ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "shawn.du" <shawn...@neulion.com.cn>
Subject Re: create singleton instance in ignite server side.
Date Mon, 18 Dec 2017 06:28:11 GMT
<html>
<head>
    <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
</head>
<body>
<style>
    font{
        line-height: 1.7;
    }
</style>
<div style = 'font-family:"微软雅黑"; font-size: 14px; color:#000000; line-height:1.7;'>
    <div>
<div><span>fixed.&nbsp;</span></div><div>Some library is
missing.</div>
<div><span><br></span></div>
<div><span><br></span></div>
<div id="ntes-pcmail-signature" style="font-family:'微软雅黑'">
    <style type="text/css">
        a#ntes-pcmail-signature-default:hover {
            text-decoration: underline;
            color: #199cff;
            cursor: pointer;
        }
        a#ntes-pcmail-signature-default:active {
            text-decoration: underline;
            color: #246fce;
            cursor: pointer;
        }
    </style>

                <div style="font-size:14px; padding: 0;  margin:0;">
                    <div style="font-family:&quot;微软雅黑&quot;; font-size:
13px; color:#000000">
    <style>
        font{
            line-height: 1.5;
        }
    </style>
<div id="ntes-pcmail-signature-default" style="font-size:14px; color:#000; text-decoration:
none;">Thanks</div><div id="ntes-pcmail-signature-default" style="font-size:14px;
color:#000; text-decoration: none;">Shawn</div>
</div>
                </div>

</div><br>
</div><div class="J-reply" style="background-color:#f2f2f2;color:black;padding-top:6px;padding-bottom:6px;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;margin-top:45px;margin-bottom:20px;font-family:'微软雅黑';">
    <div style="font-size:14px;line-height:1.5;word-break:break-all;margin-left:10px;margin-right:10px">On
<span class="mail-date">12/18/2017 13:20</span>,<a class="mail-to" style="text-decoration:none;color:#2a83f2;"
href="mailto:shawn.du@neulion.com.cn">shawn.du&lt;shawn.du@neulion.com.cn&gt;</a>
wrote: </div>
</div>
<blockquote id="ntes-pcmail-quote" style="margin: 0; padding: 0; font-size: 14px; font-family:
'微软雅黑';">

<style>
    font{
        line-height: 1.7;
    }
</style>
<div style="font-family:&quot;微软雅黑&quot;; font-size: 14px; color:#000000;
line-height:1.7;">
    
<div><span>Hi,</span></div><div><span><br></span></div><div><span>I
am using&nbsp;</span><a href="https://github.com/RuedigerMoeller/fast-serialization"
_src="https://github.com/RuedigerMoeller/fast-serialization" style="line-height: 1.7;">https://github.com/RuedigerMoeller/fast-serialization</a>&nbsp;for
ser/des.</div><div><br></div><div>my code is rather simple</div><div><br></div><div><pre
style="background-color:#2b2b2b;color:#a9b7c6;font-family:'宋体';font-size:9.0pt;"><span
style="color:#cc7832;">public class </span>EncoderSerDes<br>{<br>   
<span style="color:#cc7832;">private static </span>ISerDes <span style="color:#9876aa;font-style:italic;">serDes
</span>= <span style="color:#cc7832;">new </span>FstSerDes()<span style="color:#cc7832;">;<br></span><span
style="color:#cc7832;"><br></span><span style="color:#cc7832;">    public
static byte</span>[] <span style="color:#ffc66d;">serialize</span>(ColumnEncoder
encoder) <span style="color:#cc7832;">throws </span>Exception<br>    {<br>
       <span style="color:#cc7832;">return </span><span style="color:#9876aa;font-style:italic;">serDes</span>.serialize(encoder)<span
style="color:#cc7832;">;<br></span><span style="color:#cc7832;">    </span>}<br><br>
   <span style="color:#cc7832;">public static </span>ColumnEncoder <span style="color:#ffc66d;">deserialize</span>(<span
style="color:#cc7832;">byte</span>[] bytes) <span style="color:#cc7832;">throws
</span>Exception<br>    {<br>        <span style="color:#cc7832;">return
</span><span style="color:#9876aa;font-style:italic;">serDes</span>.deserialize(bytes)<span
style="color:#cc7832;">;<br></span><span style="color:#cc7832;">    </span>}<br><br>
   <span style="color:#cc7832;">interface </span>ISerDes<br>    {<br>
       <span style="color:#cc7832;">byte</span>[] <span style="color:#ffc66d;">serialize</span>(ColumnEncoder
encoder) <span style="color:#cc7832;">throws </span>Exception<span style="color:#cc7832;">;<br></span><span
style="color:#cc7832;"><br></span><span style="color:#cc7832;">     
  </span>ColumnEncoder <span style="color:#ffc66d;">deserialize</span>(<span
style="color:#cc7832;">byte</span>[] bytes) <span style="color:#cc7832;">throws
</span>Exception<span style="color:#cc7832;">;<br></span><span
style="color:#cc7832;">    </span>}<br><br>    <span style="color:#cc7832;">static
class </span>JavaSerDes <span style="color:#cc7832;">implements </span>ISerDes<br>
   {<br><br>        <span style="color:#bbb529;">@Override<br></span><span
style="color:#bbb529;">        </span><span style="color:#cc7832;">public byte</span>[]
<span style="color:#ffc66d;">serialize</span>(ColumnEncoder encoder) <span
style="color:#cc7832;">throws </span>Exception<br>        {<br>     
      <span style="color:#cc7832;">try </span>(ByteArrayOutputStream baos = <span
style="color:#cc7832;">new </span>ByteArrayOutputStream()<span style="color:#cc7832;">;<br></span><span
style="color:#cc7832;">                 </span>ObjectOutputStream oos = <span
style="color:#cc7832;">new </span>ObjectOutputStream(baos))<br>           
{<br>                oos.writeObject(encoder)<span style="color:#cc7832;">;<br></span><span
style="color:#cc7832;">                return </span>baos.toByteArray()<span style="color:#cc7832;">;<br></span><span
style="color:#cc7832;">            </span>}<br>        }<br><br>
       <span style="color:#bbb529;">@Override<br></span><span style="color:#bbb529;">
       </span><span style="color:#cc7832;">public </span>ColumnEncoder <span
style="color:#ffc66d;">deserialize</span>(<span style="color:#cc7832;">byte</span>[]
bytes) <span style="color:#cc7832;">throws </span>Exception<br>        {<br>
           <span style="color:#cc7832;">try </span>(ByteArrayInputStream bais
= <span style="color:#cc7832;">new </span>ByteArrayInputStream(bytes)<span
style="color:#cc7832;">;<br></span><span style="color:#cc7832;">    
            </span>ObjectInputStream ois = <span style="color:#cc7832;">new </span>ObjectInputStream(bais))<br>
           {<br>                <span style="color:#cc7832;">return </span>(ColumnEncoder)
ois.readObject()<span style="color:#cc7832;">;<br></span><span style="color:#cc7832;">
           </span>}<br>        }<br>    }<br><br>    <span
style="color:#cc7832;">static class </span>FstSerDes <span style="color:#cc7832;">implements
</span>ISerDes<br>    {<br>        <span style="color:#cc7832;">private
static </span>FSTConfiguration <span style="color:#9876aa;font-style:italic;">conf
</span>= FSTConfiguration.<span style="font-style:italic;">createDefaultConfiguration</span>()<span
style="color:#cc7832;">;<br></span><span style="color:#cc7832;"><br></span><span
style="color:#cc7832;">        static<br></span><span style="color:#cc7832;">
       </span>{<br>            <span style="color:#9876aa;font-style:italic;">conf</span>.registerClass(ArrayEncoder.<span
style="color:#cc7832;">class,<br></span><span style="color:#cc7832;">
                   ...</span><span style="color:#cc7832;"><br></span><span
style="color:#cc7832;">                    </span>Column.<span style="color:#cc7832;">class</span>)<span
style="color:#cc7832;">;<br></span><span style="color:#cc7832;">    
   </span>}<br><br>        <span style="color:#bbb529;">@Override<br></span><span
style="color:#bbb529;">        </span><span style="color:#cc7832;">public byte</span>[]
<span style="color:#ffc66d;">serialize</span>(ColumnEncoder encoder) <span
style="color:#cc7832;">throws </span>Exception<br>        {<br>     
      <span style="color:#cc7832;">return </span><span style="color:#9876aa;font-style:italic;">conf</span>.asByteArray(encoder)<span
style="color:#cc7832;">;<br></span><span style="color:#cc7832;">    
   </span>}<br><br>        <span style="color:#bbb529;">@Override<br></span><span
style="color:#bbb529;">        </span><span style="color:#cc7832;">public </span>ColumnEncoder
<span style="color:#ffc66d;">deserialize</span>(<span style="color:#cc7832;">byte</span>[]
bytes) <span style="color:#cc7832;">throws </span>Exception<br>        {<br>
           <span style="color:#cc7832;">return </span>(ColumnEncoder) <span
style="color:#9876aa;font-style:italic;">conf</span>.asObject(bytes)<span style="color:#cc7832;">;<br></span><span
style="color:#cc7832;">        </span>}<br>    }<br><br>}</pre></div>
<div><span><br></span></div>
<div>when this code run in ignite server side. it throws</div><div><br></div><div>Exception
in thread "pub-#173" java.lang.NoClassDefFoundError: Could not initialize class encoder.EncoderSerDes</div><div><br></div><div>How
to use singleton instance in ignite server side? &nbsp;I read doc &nbsp;<a href="https://apacheignite.readme.io/docs/cluster-singletons"
_src="https://apacheignite.readme.io/docs/cluster-singletons" style="line-height: 1.7;">https://apacheignite.readme.io/docs/cluster-singletons</a></div><div>but
It is not so clear for me. it is the right way for me? and how to call the singleton service?</div><div><span><br></span></div><div><span><br></span></div>
<div id="ntes-pcmail-signature" style="font-family:'微软雅黑'">
    <style type="text/css">
        a#ntes-pcmail-signature-default:hover {
            text-decoration: underline;
            color: #199cff;
            cursor: pointer;
        }
        a#ntes-pcmail-signature-default:active {
            text-decoration: underline;
            color: #246fce;
            cursor: pointer;
        }
    </style>

                <div style="font-size:14px; padding: 0;  margin:0;">
                    <div style="font-family:&quot;微软雅黑&quot;; font-size:
13px; color:#000000">
    <style>
        font{
            line-height: 1.5;
        }
    </style>
<div id="ntes-pcmail-signature-default" style="font-size:14px; color:#000; text-decoration:
none;">Thanks</div><div id="ntes-pcmail-signature-default" style="font-size:14px;
color:#000; text-decoration: none;">Shawn</div>
</div>
                </div>

</div><br>
<!--😀-->
</div></blockquote><!--😀-->
</div>
</body>
</html>
Mime
View raw message