• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 3268

Show
Ignore:
Timestamp:
01/12/09 08:49:33 (6 months ago)
Author:
jmoore
Message:

OmeroClustering : Various fixes for the jdbc version

  • Properties must be passed via the descriptor not internal.cfg
  • Needed to catch various exceptions and better handle cleanup

(cherry picked from commit 0df94cf5fd89fbc63f011fb3a25bf3f34df1b9be)

Location:
trunk
Files:
4 modified

  • components/blitz/src/ome/services/blitz/fire/Ring.java (modified) (11 diffs)
  • components/blitz/test/ome/services/blitz/test/ClusteredRingTest.java (modified) (1 diff)
  • etc/grid/templates.xml (modified) (1 diff)
  • etc/internal.cfg (modified) (1 diff)

Legend:

Unmodified
Added
Removed
  • trunk/components/blitz/src/ome/services/blitz/fire/Ring.java

    r3266 r3268  
    3434import org.springframework.context.event.ContextClosedEvent; 
    3535import org.springframework.dao.DataIntegrityViolationException; 
     36import org.springframework.dao.EmptyResultDataAccessException; 
    3637import org.springframework.jdbc.BadSqlGrammarException; 
    3738import org.springframework.jdbc.core.simple.ParameterizedRowMapper; 
    … …  
    5657 *@since Beta4 
    5758 */ 
    58 public class Ring extends _ClusterDisp implements ApplicationListener, ApplicationEventPublisherAware { 
     59public class Ring extends _ClusterDisp implements ApplicationListener, 
     60        ApplicationEventPublisherAware { 
    5961 
    6062    private final static Log log = LogFactory.getLog(Ring.class); 
    … …  
    7476    private final SimpleJdbcTemplate jdbc; 
    7577 
    76     private/*final */ApplicationEventPublisher publisher; 
    77      
     78    private/* final */ApplicationEventPublisher publisher; 
     79 
    7880    private/* final */Ice.Communicator communicator; 
    7981 
    … …  
    98100     */ 
    99101    private/* final */ClusterPrx cluster; 
    100      
     102 
    101103    /** 
    102104     * Direct proxy value to the {@link SessionManager} in this blitz instance. 
    … …  
    119121    /** 
    120122     * Passed to the {@link Discovery} instance for signalling completion from 
    121      * its background {@link Thread}  
     123     * its background {@link Thread} 
    122124     */ 
    123125    public void setApplicationEventPublisher(ApplicationEventPublisher arg0) { 
    124126        this.publisher = arg0; 
    125127    } 
    126      
     128 
    127129    // Configuration and cluster usage 
    128130    // ========================================================================= 
    … …  
    139141        // The cluster we belong to. 
    140142        Ice.ObjectPrx prx = this.communicator.propertyToProxy("ClusterProxy"); 
     143        if (prx == null) { 
     144            throw new RuntimeException("Could not obtain ClusterProxy. " 
     145                    + "Is multicast property properly set?"); 
     146        } 
    141147        prx = prx.ice_datagram(); 
     148        if (prx == null) { 
     149            throw new RuntimeException("Could no get datagram proxy. " 
     150                    + "Please check your multicast configuration."); 
     151        } 
    142152        cluster = ClusterPrxHelper.uncheckedCast(prx); 
    143          
     153 
    144154        // Before we add our self we check the validity of the cluster. 
    145155        checkClusterAndAddSelf(); 
    … …  
    182192            log.info("Sent cluster node uuid: " + uuid); 
    183193        } catch (Exception e) { 
    184             log.warn("Exception while sending cluster node uuid: "+uuid, e); 
    185         } 
    186     } 
    187  
    188     /** 
    189      * Called when any node goes down. First we try to remove any redirect for that 
    190      * instance. Then we try to install ourselves. 
     194            log.warn("Exception while sending cluster node uuid: " + uuid, e); 
     195        } 
     196    } 
     197 
     198    /** 
     199     * Called when any node goes down. First we try to remove any redirect for 
     200     * that instance. Then we try to install ourselves. 
    191201     */ 
    192202    public void down(String downUuid, Current __current) { 
    193         removeIfEquals(CONFIG+"redirect", downUuid); 
    194         if (putIfAbsent(CONFIG+"redirect", this.uuid)) { 
    195             log.info("Installed self as new redirect: "+uuid); 
    196         } 
    197     } 
    198      
     203        removeIfEquals(CONFIG + "redirect", downUuid); 
     204        if (putIfAbsent(CONFIG + "redirect", this.uuid)) { 
     205            log.info("Installed self as new redirect: " + uuid); 
     206        } 
     207    } 
     208 
    199209    public void destroy() { 
    200210        try { 
    201211            this.clusterAdapter.deactivate(); 
    202             cluster.down(this.uuid); 
    203212            remove(MANAGERS + uuid); 
    204             removeIfEquals(CONFIG+"redirect", uuid); 
     213            int count = jdbc.update("delete from session_ring where value = ?", uuid); 
     214            log.info("Removed "+count+" entries for "+uuid); 
    205215            log.info("Disconnected from OMERO.cluster"); 
    206216        } catch (Exception e) { 
    207217            log.error("Error stopping ring " + this, e); 
     218        } finally { 
     219            cluster.down(this.uuid); 
    208220        } 
    209221    } 
    … …  
    330342        return rv; 
    331343    } 
    332      
     344 
    333345    public void assertNodes(Set<String> nodeUuids) { 
    334346        Set<String> managers = knownManagers(); 
    335347        for (String manager : managers) { 
    336             System.out.println(manager+"?="+nodeUuids); 
    337348            if (!nodeUuids.contains(manager)) { 
    338                 purgeNode(manager); 
     349                // Also verify this is not ourself, since 
     350                // possibly we haven't finished registration 
     351                // yet 
     352                if (!uuid.equals(manager)) { 
     353                    purgeNode(manager); 
     354                } 
    339355            } 
    340356        } 
    … …  
    387403 
    388404    public String get(String key) { 
    389         String value = (String) jdbc.queryForObject("select value " 
    390                 + "from session_ring " + "where key = ?", String.class, key); 
    391         return value; 
     405        try { 
     406            String value = (String) jdbc 
     407                    .queryForObject("select value " + "from session_ring " 
     408                            + "where key = ?", String.class, key); 
     409            return value; 
     410        } catch (EmptyResultDataAccessException erdae) { 
     411            return null; 
     412        } 
    392413    } 
    393414 
    … …  
    401422                log.info("Key not found for update: " + key); 
    402423            } else { 
    403                 log.info(String.format("Updated key %s with value %s", key, 
    404                         value)); 
     424                log.info(String.format("Updated key %s to %s", key, value)); 
    405425            } 
    406426        } 
    … …  
    444464     */ 
    445465    public boolean removeIfEquals(String key, String value) { 
    446         int count = jdbc 
    447                 .update("delete from session_ring where key = ? and value = ?", key, value); 
     466        int count = jdbc.update( 
     467                "delete from session_ring where key = ? and value = ?", key, 
     468                value); 
    448469        if (count == 0) { 
    449470            log.info("Key and value do not match: " + key + "=" + value); 
  • trunk/components/blitz/test/ome/services/blitz/test/ClusteredRingTest.java

    r3266 r3268  
    147147        fail(); 
    148148    } 
     149     
     150    @Test 
     151    public void testIfRedirectIsDeletedAnotherHostTakesOver() throws Exception { 
     152        fails(); 
     153    } 
    149154} 
  • trunk/etc/grid/templates.xml

    r3239 r3268  
    2626          <property name="Ice.MessageSizeMax" value="65536"/> <!-- 64 MB --> 
    2727          <property name="Ice.Default.CollocationOptimized" value="0"/> 
     28          <!-- used to communicate between instances. See omero/Internal.ice --> 
     29          <property name="Cluster.Endpoints" value="udp -h 239.0.0.5 -p 22222"/> 
     30          <property name="ClusterProxy" value="Cluster:udp -h 239.0.0.5 -p 22222"/> 
    2831        </properties> 
    2932      </server> 
  • trunk/etc/internal.cfg

    r3266 r3268  
    66IceGridAdmin.Username=root 
    77IceGridAdmin.Password=ome 
    8  
    9 # 
    10 # Used to communicate between instances 
    11 # See: omero/Internal.ice 
    12 # 
    13 Cluster.Endpoints=udp -h 239.0.0.5 -p 22222 
    14 ClusterProxy=Cluster:udp -h 239.0.0.5 -p 22222 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/