示例#1
0
 public void onMessage(Jedis j, String channel, String message) {
   synchronized (j) {
     if ("property".equals(channel)) {
       // Called when Redis publish a property update.
       String propertyName = message;
       IProperty property = this.localState.getHierarchy().getProperty(propertyName);
       String value = j.get(propertyName);
       if (value != null) {
         property.setValue(value);
       } else {
         property.clearValue();
       }
       String link = j.get(propertyName + "#link");
       if (link != null) {
         property.setLink(link);
       } else {
         property.clearLink();
       }
     } else if ("contest".equals(channel)) {
       if (REDIS_CONTEST_SYNC) {
         // Called when Redis publish a contest update.
         String[] keys = message.split("\\.", 4);
         assert (keys.length == 4);
         assert (keys[0].equals("contest"));
         ContestId contestId = new ContestId(keys[1], Long.valueOf(keys[2]));
         Set<String> fields = j.smembers(message + ".fields");
         String type = j.get(message + ".type");
         AttrsUpdateEventImpl e = new AttrsUpdateEventImpl(0, type);
         for (String field : fields) {
           e.setProperty(field, j.get(message + "." + field));
         }
         // DebugTrace.trace(e.toString());
         localState.getContest(contestId).attrsUpdated(e);
       }
     }
   }
 }