Пример #1
0
 @Override
 public void changed() {
   String masterUrl = null;
   GitNode[] masters = watcher.masters();
   if (masters != null
       && masters.length > 0
       && !masters[0].getAgent().equals(System.getProperty("karaf.name"))) {
     masterUrl = masters[0].getUrl();
   }
   try {
     StoredConfig config = get().getRepository().getConfig();
     if (masterUrl != null) {
       config.setString(
           "remote",
           "origin",
           "url",
           ZooKeeperUtils.getSubstitutedData(zookeeper, masters[0].getUrl()));
       config.setString("remote", "origin", "fetch", "+refs/heads/*:refs/remotes/origin/*");
     } else {
       config.unsetSection("remote", "origin");
     }
     config.save();
   } catch (Exception e) {
     LOGGER.error("Failed to point origin to the new master.", e);
   }
 }
Пример #2
0
 @Override
 public void onDisconnected() {
   watcher.stop();
   group.close();
 }
Пример #3
0
 @Override
 public void onConnected() {
   group = ZooKeeperGroupFactory.create(zookeeper, ZkPath.GIT.getPath());
   group.add(this);
   watcher.start(group);
 }