[jboss-cvs] JBossCache/src/org/jboss/cache/loader/tcp ...

Manik Surtani msurtani at jboss.com
Fri Sep 22 12:27:56 EDT 2006


  User: msurtani
  Date: 06/09/22 12:27:56

  Modified:    src/org/jboss/cache/loader/tcp  TcpCacheServer.java
  Log:
  - Modification types to Enums.
  - Abstracted put(List)
  
  Revision  Changes    Path
  1.19      +61 -13    JBossCache/src/org/jboss/cache/loader/tcp/TcpCacheServer.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TcpCacheServer.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/tcp/TcpCacheServer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- TcpCacheServer.java	7 Sep 2006 13:52:28 -0000	1.18
  +++ TcpCacheServer.java	22 Sep 2006 16:27:56 -0000	1.19
  @@ -34,7 +34,7 @@
    * TCP-IP based CacheServer, configure TcpDelegatingCacheLoader with host and port of this server
    *
    * @author Bela Ban
  - * @version $Id: TcpCacheServer.java,v 1.18 2006/09/07 13:52:28 msurtani Exp $
  + * @version $Id: TcpCacheServer.java,v 1.19 2006/09/22 16:27:56 msurtani Exp $
    */
   public class TcpCacheServer implements TcpCacheServerMBean
   {
  @@ -63,8 +63,10 @@
      public void setBindAddress(String bind_addr) throws UnknownHostException
      {
         if (bind_addr != null)
  +      {
            this.bind_addr = InetAddress.getByName(bind_addr);
      }
  +   }
   
      public int getPort()
      {
  @@ -145,7 +147,9 @@
         }
   
         if (cache == null)
  +      {
            throw new CacheException("cache reference is not set");
  +      }
   
   
         srv_sock = new ServerSocket(port, 10, bind_addr);
  @@ -236,9 +240,27 @@
         public void close()
         {
            t = null;
  -         try {if (output != null) output.close();} catch (Throwable th) {}
  -         try {if (input != null) input.close();} catch (Throwable th) {}
  -         try {if (sock != null) sock.close();} catch (Throwable th) {}
  +         try
  +         {
  +            if (output != null) output.close();
  +         }
  +         catch (Throwable th)
  +         {
  +         }
  +         try
  +         {
  +            if (input != null) input.close();
  +         }
  +         catch (Throwable th)
  +         {
  +         }
  +         try
  +         {
  +            if (sock != null) sock.close();
  +         }
  +         catch (Throwable th)
  +         {
  +         }
         }
   
         public void run()
  @@ -260,9 +282,27 @@
               catch (IOException e)
               {
                  mylog.warn("failed reading data, thread will terminate", e);
  -               try {if (output != null) output.close();} catch (Throwable th) {}
  -               try {if (input != null) input.close();} catch (Throwable th) {}
  -               try {if (sock != null) sock.close();} catch (Throwable th) {}
  +               try
  +               {
  +                  if (output != null) output.close();
  +               }
  +               catch (Throwable th)
  +               {
  +               }
  +               try
  +               {
  +                  if (input != null) input.close();
  +               }
  +               catch (Throwable th)
  +               {
  +               }
  +               try
  +               {
  +                  if (sock != null) sock.close();
  +               }
  +               catch (Throwable th)
  +               {
  +               }
                  break;
               }
   
  @@ -355,13 +395,17 @@
                     case DelegatingCacheLoader.delegateLoadEntireState:
                        ObjectOutputStream os = (ObjectOutputStream) input.readObject();
                        if (c.getCacheLoader() != null)
  +                     {
                           c.getCacheLoader().loadEntireState(os);
  +                     }
                        output.writeObject(Boolean.TRUE);
                        break;
                     case DelegatingCacheLoader.delegateStoreEntireState:
                        ObjectInputStream is = (ObjectInputStream) input.readObject();
                        if (c.getCacheLoader() != null)
  +                     {
                           c.getCacheLoader().storeEntireState(is);
  +                     }
                        output.writeObject(Boolean.TRUE);
                        break;
                     default:
  @@ -398,29 +442,33 @@
   
         protected void handleModifications(List modifications) throws CacheException
         {
  +
            for (Iterator it = modifications.iterator(); it.hasNext();)
            {
               Modification m = (Modification) it.next();
               switch (m.getType())
               {
  -               case Modification.PUT_DATA:
  +               case PUT_DATA:
                     c.put(m.getFqn(), m.getData());
                     break;
  -               case Modification.PUT_DATA_ERASE:
  +               case PUT_DATA_ERASE:
                     c.put(m.getFqn(), m.getData());
                     break;
  -               case Modification.PUT_KEY_VALUE:
  +               case PUT_KEY_VALUE:
                     c.put(m.getFqn(), m.getKey(), m.getValue());
                     break;
  -               case Modification.REMOVE_DATA:
  +               case REMOVE_DATA:
                     c.removeData(m.getFqn());
                     break;
  -               case Modification.REMOVE_KEY_VALUE:
  +               case REMOVE_KEY_VALUE:
                     c.remove(m.getFqn(), m.getKey());
                     break;
  -               case Modification.REMOVE_NODE:
  +               case REMOVE_NODE:
                     c.remove(m.getFqn());
                     break;
  +               case MOVE:
  +                  c.move(m.getFqn(), m.getFqn2());
  +                  break;
                  default:
                     mylog.error("modification type " + m.getType() + " not known");
                     break;
  
  
  



More information about the jboss-cvs-commits mailing list