Ejemplo n.º 1
0
		@EventHandler(priority = EventPriority.HIGHEST)
		public void onPlayerJoin(final PlayerJoinEvent event)
		{
			final User user = ess.getUser(event.getPlayer());
			if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
			{
				return;
			}

			try
			{
				sendToJail(user, user.getJail());
			}
			catch (Exception ex)
			{
				if (ess.getSettings().isDebug())
				{
					LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
				}
				else
				{
					LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
				}
			}
			user.sendMessage(_("jailMessage"));
		}
Ejemplo n.º 2
0
  /** Called when a module build that corresponds to this module set build has completed. */
  /* package */ void notifyModuleBuild(IvyBuild newBuild) {
    try {
      // update module set build number
      getParent().updateNextBuildNumber();

      // update actions
      Map<IvyModule, List<IvyBuild>> moduleBuilds = getModuleBuilds();

      // actions need to be replaced atomically especially
      // given that two builds might complete simultaneously.
      synchronized (this) {
        boolean modified = false;

        List<Action> actions = getActions();
        Set<Class<? extends AggregatableAction>> individuals =
            new HashSet<Class<? extends AggregatableAction>>();
        for (Action a : actions) {
          if (a instanceof IvyAggregatedReport) {
            IvyAggregatedReport mar = (IvyAggregatedReport) a;
            mar.update(moduleBuilds, newBuild);
            individuals.add(mar.getIndividualActionType());
            modified = true;
          }
        }

        // see if the new build has any new aggregatable action that we
        // haven't seen.
        for (AggregatableAction aa : newBuild.getActions(AggregatableAction.class)) {
          if (individuals.add(aa.getClass())) {
            // new AggregatableAction
            IvyAggregatedReport mar = aa.createAggregatedAction(this, moduleBuilds);
            mar.update(moduleBuilds, newBuild);
            actions.add(mar);
            modified = true;
          }
        }

        if (modified) {
          save();
          getProject().updateTransientActions();
        }
      }

      // symlink to this module build
      String moduleFsName = newBuild.getProject().getModuleName().toFileSystemName();
      Util.createSymlink(
          getRootDir(),
          "../../modules/" + moduleFsName + "/builds/" + newBuild.getId() /*ugly!*/,
          moduleFsName,
          StreamTaskListener.NULL);
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, "Failed to update " + this, e);
    } catch (InterruptedException e) {
      LOGGER.log(Level.WARNING, "Failed to update " + this, e);
    }
  }
Ejemplo n.º 3
0
  /**
   * This method tries to compute the name of the host that's reachable by all the other nodes.
   *
   * <p>Since it's possible that the slave is not reachable from the master (it may be behind a
   * firewall, connecting to master via JNLP), this method may return null.
   *
   * <p>It's surprisingly tricky for a machine to know a name that other systems can get to,
   * especially between things like DNS search suffix, the hosts file, and YP.
   *
   * <p>So the technique here is to compute possible interfaces and names on the slave, then try to
   * ping them from the master, and pick the one that worked.
   *
   * <p>The computation may take some time, so it employs caching to make the successive lookups
   * faster.
   *
   * @since 1.300
   * @return null if the host name cannot be computed (for example because this computer is offline,
   *     because the slave is behind the firewall, etc.)
   */
  public String getHostName() throws IOException, InterruptedException {
    if (hostNameCached)
      // in the worst case we end up having multiple threads computing the host name simultaneously,
      // but that's not harmful, just wasteful.
      return cachedHostName;

    VirtualChannel channel = getChannel();
    if (channel == null) return null; // can't compute right now

    for (String address : channel.call(new ListPossibleNames())) {
      try {
        InetAddress ia = InetAddress.getByName(address);
        if (!(ia instanceof Inet4Address)) {
          LOGGER.fine(address + " is not an IPv4 address");
          continue;
        }
        if (!ComputerPinger.checkIsReachable(ia, 3)) {
          LOGGER.fine(address + " didn't respond to ping");
          continue;
        }
        cachedHostName = ia.getCanonicalHostName();
        hostNameCached = true;
        return cachedHostName;
      } catch (IOException e) {
        // if a given name fails to parse on this host, we get this error
        LOGGER.log(Level.FINE, "Failed to parse " + address, e);
      }
    }

    // allow the administrator to manually specify the host name as a fallback. HUDSON-5373
    cachedHostName = channel.call(new GetFallbackName());
    hostNameCached = true;
    return cachedHostName;
  }