Ejemplo n.º 1
0
    /**
     * WARNING: beware of hacks.
     *
     * <p>Fails a member of this cluster by making it not respond to heart beats. A {@link
     * RepairKit} is returned which is able to repair the instance (i.e start the network) again.
     *
     * @param db the {@link HighlyAvailableGraphDatabase} to fail.
     * @return a {@link RepairKit} which can repair the failure.
     * @throws IllegalArgumentException if the given db isn't a member of this cluster.
     */
    public RepairKit fail(HighlyAvailableGraphDatabase db) throws Throwable {
      assertMember(db);
      ClusterClient clusterClient =
          db.getDependencyResolver().resolveDependency(ClusterClient.class);
      LifeSupport clusterClientLife =
          (LifeSupport)
              accessible(clusterClient.getClass().getDeclaredField("life")).get(clusterClient);

      NetworkReceiver receiver =
          instance(NetworkReceiver.class, clusterClientLife.getLifecycleInstances());
      receiver.stop();

      ExecutorLifecycleAdapter statemachineExecutor =
          instance(ExecutorLifecycleAdapter.class, clusterClientLife.getLifecycleInstances());
      statemachineExecutor.stop();

      NetworkSender sender =
          instance(NetworkSender.class, clusterClientLife.getLifecycleInstances());
      sender.stop();

      List<Lifecycle> stoppedServices = new ArrayList<>();
      stoppedServices.add(sender);
      stoppedServices.add(statemachineExecutor);
      stoppedServices.add(receiver);

      return new StartNetworkAgainKit(db, stoppedServices);
    }
Ejemplo n.º 2
0
    /**
     * WARNING: beware of hacks.
     *
     * <p>Fails a member of this cluster by making it not respond to heart beats. A {@link
     * RepairKit} is returned which is able to repair the instance (i.e start the network) again.
     *
     * @param db the {@link HighlyAvailableGraphDatabase} to fail.
     * @return a {@link RepairKit} which can repair the failure.
     * @throws IllegalArgumentException if the given db isn't a member of this cluster.
     */
    public RepairKit fail(HighlyAvailableGraphDatabase db) throws Throwable {
      assertMember(db);
      ClusterClient clusterClient =
          db.getDependencyResolver().resolveDependency(ClusterClient.class);
      LifeSupport clusterClientLife =
          (LifeSupport)
              accessible(clusterClient.getClass().getDeclaredField("life")).get(clusterClient);
      NetworkInstance network =
          instance(NetworkInstance.class, clusterClientLife.getLifecycleInstances());
      network.stop();

      int serverId =
          db.getDependencyResolver().resolveDependency(Config.class).get(HaSettings.server_id);
      db.shutdown();
      return new StartDatabaseAgainKit(this, serverId);
    }