private boolean workaroundBug356918(
     HttpServletRequest request, HttpServletResponse response, Exception e)
     throws ServletException, JSONException {
   if (e instanceof CheckoutConflictException) {
     JSONObject result = new JSONObject();
     result.put(GitConstants.KEY_RESULT, MergeStatus.FAILED.name());
     Map<String, MergeFailureReason> failingPaths = new HashMap<String, MergeFailureReason>();
     String[] files = e.getMessage().split("\n"); // $NON-NLS-1$
     for (int i = 1; i < files.length; i++) {
       // TODO: this is not always true, but it's a temporary workaround
       failingPaths.put(files[i], MergeFailureReason.DIRTY_WORKTREE);
     }
     result.put(GitConstants.KEY_FAILING_PATHS, failingPaths);
     try {
       OrionServlet.writeJSONResponse(
           request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
       return true;
     } catch (IOException e1) {
       e = e1;
     }
   }
   return statusHandler.handleRequest(
       request,
       response,
       new ServerStatus(
           IStatus.ERROR,
           HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
           "An error occured when merging.",
           e.getCause()));
 }
Example #2
0
 Object createGuiElement(Class cls, EntityPlayer player, World world, int x, int y, int z) {
   try {
     try {
       if (debugGui)
         System.out.printf(
             "BaseMod.createGuiElement: Invoking create method of %s for %s in %s\n",
             cls, player, world);
       return cls.getMethod(
               "create", EntityPlayer.class, World.class, int.class, int.class, int.class)
           .invoke(null, player, world, x, y, z);
     } catch (NoSuchMethodException e) {
       if (debugGui)
         System.out.printf("BaseMod.createGuiElement: Invoking constructor of %s\n", cls);
       return cls.getConstructor(EntityPlayer.class, World.class, int.class, int.class, int.class)
           .newInstance(player, world, x, y, z);
     }
   } catch (Exception e) {
     Throwable cause = e.getCause();
     System.out.printf("BaseMod.createGuiElement: %s: %s\n", e, cause);
     if (cause != null) cause.printStackTrace();
     else e.printStackTrace();
     // throw new RuntimeException(e);
     return null;
   }
 }
  public static void main(String args[]) {
    Config.setClientMode(true);
    LoaderOptions options = LoaderOptions.parseArgs(args);
    OutputHandler handler = new OutputHandler.SystemOutput(options.verbose, options.debug);
    SSTableLoader loader =
        new SSTableLoader(
            options.directory,
            new ExternalClient(
                options.hosts,
                options.rpcPort,
                options.user,
                options.passwd,
                options.transportFactory,
                options.storagePort,
                options.sslStoragePort,
                options.serverEncOptions),
            handler);
    DatabaseDescriptor.setStreamThroughputOutboundMegabitsPerSec(options.throttle);
    StreamResultFuture future = null;
    try {
      if (options.noProgress) future = loader.stream(options.ignores);
      else future = loader.stream(options.ignores, new ProgressIndicator());
    } catch (Exception e) {
      System.err.println(e.getMessage());
      if (e.getCause() != null) System.err.println(e.getCause());
      if (options.debug) e.printStackTrace(System.err);
      else System.err.println("Run with --debug to get full stack trace or --help to get help.");
      System.exit(1);
    }

    handler.output(String.format("Streaming session ID: %s", future.planId));

    try {
      future.get();
      System.exit(0); // We need that to stop non daemonized threads
    } catch (Exception e) {
      System.err.println("Streaming to the following hosts failed:");
      System.err.println(loader.getFailedHosts());
      System.err.println(e);
      if (options.debug) e.printStackTrace(System.err);
      System.exit(1);
    }
  }
Example #4
0
  public void restartApplication() {

    try {

      final String javaBin =
          System.getProperty("java.home") + File.separator + "bin" + File.separator + "javaw";
      final File currentJar =
          new File(network.class.getProtectionDomain().getCodeSource().getLocation().toURI());

      System.out.println("javaBin " + javaBin);
      System.out.println("currentJar " + currentJar);
      System.out.println("currentJar.getPath() " + currentJar.getPath());

      /* is it a jar file? */
      // if(!currentJar.getName().endsWith(".jar")){return;}

      try {

        // xmining = 0;
        // systemx.shutdown();

      } catch (Exception e) {
        e.printStackTrace();
      }

      /* Build command: java -jar application.jar */
      final ArrayList<String> command = new ArrayList<String>();
      command.add(javaBin);
      command.add("-jar");
      command.add("-Xms256m");
      command.add("-Xmx1024m");
      command.add(currentJar.getPath());

      final ProcessBuilder builder = new ProcessBuilder(command);
      builder.start();

      // try{Thread.sleep(10000);} catch (InterruptedException e){}

      // close and exit
      SystemTray.getSystemTray().remove(network.icon);
      System.exit(0);

    } // try
    catch (Exception e) {
      JOptionPane.showMessageDialog(null, e.getCause());
    }
  } // ******************************
    @Override
    public void run() {
      try {
        processTime = System.currentTimeMillis();
        myPack = (Pack) ois.readObject();
        functionName = myPack.getfunctionName();
        paramTypes = myPack.getparamTypes();
        paramValues = myPack.getparamValues();
        state = myPack.getstate();
        stateDType = myPack.getstateType();
        timestamps = myPack.getTimeStamps();

        if (functionName != null && functionName.length() > 0) {
          try {

            System.out.println("Trying to load and execute");
            Class cls = Class.forName(stateDType.getName());

            timestamps.add(processTime + ",server1");

            /*System.out.println(""+stateDType.getName());

            System.out.println("functionsName: " + functionName.toLowerCase());
            System.out.println("paramTypes: " + paramTypes.toString());*/

            Method method = cls.getDeclaredMethod(functionName, paramTypes);

            try {

              /** support for caching results */

              /** cache using the parameters as key of the result can be possible */
              // boolean processed = TreeManager.getInstance().exists(paramValues[0]);

              // System.out.println("param1:" + (int[]) paramValues[0]);
              // System.out.println("param1:" + paramValues[1]);
              // System.out.println("param1:" +  paramValues[2]);

              oos.flush();
              Object result = method.invoke(state, paramValues);
              ResultPack rp = new ResultPack(result, state);

              rp.setTimeStamps(timestamps);

              // System.out.println("Size in bytes: " + sizeInBytes(rp));
              oos.flush();
              oos.writeObject(rp);
              // System.out.println("Object wrote it");
              oos.flush();
              // System.out.println("Object executed and flushed: " + (System.currentTimeMillis() -
              // processTime));

              System.out.println("Object executed and flushed:");

              // System.out.println("Object executed and flushed: " + (System.currentTimeMillis() -
              // processTime));

            } catch (IllegalAccessException ex1) {
              returnnull(oos);
              System.out.println("Hubo problema 1: " + ex1.getMessage());
            } catch (InvocationTargetException ex2) {
              returnnull(oos);
              System.out.println("Hubo problema 2: " + ex2.getCause());
            } catch (Exception ex3) {
              ResultPack rp = new ResultPack(null, state);
              oos.writeObject(rp);
              oos.flush();
              System.out.println("Hubo problema 3" + ex3.getCause());
            }

          } catch (ClassNotFoundException ex) {
            returnnull(oos);
            System.out.println("Hubo problema 4");
          } catch (IllegalArgumentException ex) {
            returnnull(oos);
            System.out.println("Hubo problema 5");
          } catch (NoSuchMethodException ex) {
            returnnull(oos);
            System.out.println("Hubo problema 6");
          } catch (SecurityException ex) {
            returnnull(oos);
            System.out.println("Hubo problema 7");
          } finally {

            oos.close();
            ois.close();

            in.close();
            out.close();

            mysocket.close();

            oos = null;
            ois = null;

            in = null;
            out = null;
            mysocket = null;
          }
        } else {
          returnnull(oos);
        }
      } catch (IOException ex) {
        returnnull(oos);
        System.out.println("Hubo problema 8");
      } catch (ClassNotFoundException ex) {
        returnnull(oos);
        System.out.println("Hubo problema 9");
        ex.printStackTrace();
      } finally {
        makeconnection();
      }
    }