예제 #1
1
  /**
   * 停用访客策略
   *
   * @param fangke
   * @param request
   * @return
   */
  @RequestMapping(value = "/removeInvalidrfid.do")
  public boolean doRemoveInvalidrfid() {

    // fangkeService.remove(fangke);
    log.info("删除访客策略数据");

    CommandProtocal command = new CommandProtocal();
    command.setCommandType(CommandType.DELETE); // 删除类型
    command.setJopName("invalidrfid"); // 决策的ID,和数据库中保存一致
    command.setStrategyType(StrategyType.VISITOR); // 无意义

    /** 设置监控的规则* */
    CommandBody body = new CommandBody();
    command.setBody(body);

    try {
      CommandMinaClient client = CommandMinaClient.getCommandMinaClient();
      // 到远程服务器没有开启时,client为空
      if (client != null) {
        InetSocketAddress socketAddress =
            (InetSocketAddress) client.getIOSession().getLocalAddress();
        String address =
            socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort();
        command.setClientIP(address); // 设置IP地址
        log.fatal(address);
        log.fatal(client.getIOSession().getLocalAddress().toString());
        client.Send(command);
      }
    } catch (NullPointerException e) {
      log.error("客户端无法获取与服务器端的session");
      return false;
    }

    return true;
  }
예제 #2
0
 @Test
 public void updatingUser() {
   Role role = new Role("admin", "asdas, dfasd");
   User user =
       new User(
           "demon13.by",
           Password.hashPassword(Password.hashPassword("Scorpion") + Password.SALT),
           "Denis",
           "Kravchenko",
           role);
   Report report = new Report(null, new Date(), 56, 12, user);
   List<Report> reports = new ArrayList<Report>();
   reports.add(report);
   Task task = new Task(null, "asdasdasd", "asdasd", 56, "asas", new Date(), user);
   task.setReports(reports);
   TaskDAOImpl taskDao = new TaskDAOImpl();
   taskDao.addTask(task);
   log.fatal(task);
   Integer id = task.getId();
   task.setText("fjghkl");
   taskDao.addTask(task);
   log.fatal(task);
   Task newTask = taskDao.getTask(id);
   log.fatal(newTask);
   assertEquals(task, newTask);
   RoleDAOImpl roleDao = new RoleDAOImpl();
   roleDao.removeRole(role);
 }
  /** Creates a Pooled connection and adds it to the connection pool. */
  private void installConnection() throws EmanagerDatabaseException {
    logger.debug("enter");

    PooledConnection connection;

    try {
      connection = poolDataSource.getPooledConnection();
      connection.addConnectionEventListener(this);
      connection.getConnection().setAutoCommit(false);
      synchronized (connectionPool) {
        connectionPool.add(connection);
        logger.debug("Database connection added.");
      }
    } catch (SQLException ex) {
      logger.fatal("exception caught while obtaining database " + "connection: ex = " + ex);
      SQLException ex1 = ex.getNextException();
      while (ex1 != null) {
        logger.fatal("chained sql exception ex1 = " + ex1);
        SQLException nextEx = ex1.getNextException();
        ex1 = nextEx;
      }
      String logString;
      EmanagerDatabaseException ede;

      logString =
          EmanagerDatabaseStatusCode.DatabaseConnectionFailure.getStatusCodeDescription()
              + ex.getMessage();

      logger.fatal(logString);
      ede =
          new EmanagerDatabaseException(
              EmanagerDatabaseStatusCode.DatabaseConnectionFailure, logString);
      throw ede;
    }
  }
예제 #4
0
 /**
  * Call VoltDB.crashVoltDB on behalf of the EE
  *
  * @param reason Reason the EE crashed
  */
 public static void crashVoltDB(String reason, String traces[], String filename, int lineno) {
   if (reason != null) {
     LOG.fatal("ExecutionEngine requested that we crash: " + reason);
     LOG.fatal("Error was in " + filename + ":" + lineno + "\n" + StringUtil.join("\n", traces));
   }
   VoltDB.crashVoltDB();
 }
  public static void main(String argv[]) {
    // Add a bunch of logging statements ...
    logger.debug("Hello, my name is Homer Simpson.");
    logger.debug("Hello, my name is Lisa Simpson.");
    logger.debug("Hello, my name is Marge Simpson.");
    logger.debug("Hello, my name is Bart Simpson.");
    logger.debug("Hello, my name is Maggie Simpson.");

    logger.info("We are the Simpsons!");
    logger.info("Mmmmmm .... Chocolate.");
    logger.info("Homer likes chocolate");
    logger.info("Doh!");
    logger.info("We are the Simpsons!");

    logger.warn(
        "Bart: I am through with working! Working is for chumps!"
            + "Homer: Son, I'm proud of you. I was twice your age before "
            + "I figured that out.");
    logger.warn("Mmm...forbidden donut.");
    logger.warn("D'oh! A deer! A female deer!");
    logger.warn(
        "Truly, yours is a butt that won't quit." + "- Bart, writing as Woodrow to Ms. Krabappel.");

    logger.error("Dear Baby, Welcome to Dumpsville. Population: you.");
    logger.error(
        "Dear Baby, Welcome to Dumpsville. Population: you.", new IOException("Dumpsville, USA"));
    logger.error("Mr. Hutz, are you aware you're not wearing pants?");
    logger.error(
        "Mr. Hutz, are you aware you're not wearing pants?", new IllegalStateException("Error !!"));

    logger.fatal("Eep.");
    logger.fatal("Mmm...forbidden donut.", new SecurityException("Fatal Exception"));
    logger.fatal("D'oh! A deer! A female deer!");
    logger.fatal("Mmmmmm .... Chocolate.", new SecurityException("Fatal Exception"));
  }
 /**
  * These methods are not public.
  *
  * @param name
  * @param value
  */
 private void invokeHistorySetter(
     final HistoryEntry entry,
     final String name,
     final Class<?> parameterType,
     final Object value) {
   try {
     final Method method = HistoryEntry.class.getDeclaredMethod(name, parameterType);
     method.setAccessible(true);
     method.invoke(entry, value);
   } catch (final IllegalArgumentException ex) {
     log.error("Can't modify id of history entry. This results in a corrupted history: " + entry);
     log.fatal("Exception encountered " + ex, ex);
   } catch (final IllegalAccessException ex) {
     log.error("Can't modify id of history entry. This results in a corrupted history: " + entry);
     log.fatal("Exception encountered " + ex, ex);
   } catch (final InvocationTargetException ex) {
     log.error("Can't modify id of history entry. This results in a corrupted history: " + entry);
     log.fatal("Exception encountered " + ex, ex);
   } catch (final SecurityException ex) {
     log.error("Can't modify id of history entry. This results in a corrupted history: " + entry);
     log.fatal("Exception encountered " + ex, ex);
   } catch (final NoSuchMethodException ex) {
     log.error("Can't modify id of history entry. This results in a corrupted history: " + entry);
     log.fatal("Exception encountered " + ex, ex);
   }
 }
 @Override
 public void run(TransactionRedirectResponse parameter) {
   if (LOG.isTraceEnabled())
     LOG.trace(
         String.format(
             "Got back FORWARD_TXN response from %s. Sending response to client [bytes=%d]",
             HStoreSite.formatSiteName(parameter.getSenderId()), parameter.getOutput().size()));
   byte data[] = parameter.getOutput().toByteArray();
   try {
     this.orig_callback.run(data);
   } catch (Throwable ex) {
     FastDeserializer fds = new FastDeserializer(data);
     ClientResponseImpl cresponse = null;
     long txn_id = -1;
     try {
       cresponse = fds.readObject(ClientResponseImpl.class);
       txn_id = cresponse.getTransactionId();
     } catch (IOException e) {
       LOG.fatal("We're really falling apart here!", e);
     }
     LOG.fatal("Failed to forward ClientResponse data back for txn #" + txn_id, ex);
     // throw ex;
   } finally {
     try {
       this.finish();
       HStoreObjectPools.CALLBACKS_TXN_REDIRECT_REQUEST.returnObject(this);
     } catch (Exception ex) {
       throw new RuntimeException("Funky failure", ex);
     }
   }
 }
예제 #8
0
 /**
  * 裁剪出图片的中间正方形
  *
  * @param inputFilePath
  * @param outputFilePath
  */
 public static void cutSquare(String inputFilePath, String outputFilePath) {
   try {
     // 获得源文件
     File inputFile = new File(inputFilePath);
     if (!inputFile.exists()) {
       logger.fatal(new FileNotFoundException());
       return;
     }
     BufferedImage bufferedImage = ImageIO.read(inputFile);
     int width = bufferedImage.getWidth();
     int height = bufferedImage.getHeight();
     int stand = width >= height ? height : width;
     if (stand == height) {
       int x = Math.round((width - height) / 2);
       int y = Math.round(0);
       cut(inputFilePath, outputFilePath, x, y, stand, stand);
     } else {
       int x = Math.round(0);
       int y = Math.round((height - width) / 2);
       cut(inputFilePath, outputFilePath, x, y, stand, stand);
     }
   } catch (Exception e) {
     e.printStackTrace();
     logger.fatal(e);
   }
 }
 /*
  * Returns JPunch Properties
  *
  * @return Properties, null if error occurs or property set is empty
  */
 private static Properties getProperties() {
   if (jPunchProperties == null) {
     String filename = System.getProperty(JPUNCH_PROPERTIES_FILE);
     if (filename == null) {
       log.fatal("No filename in property [" + JPUNCH_PROPERTIES_FILE + "]");
       return null;
     }
     try {
       jPunchProperties = loadPoperties(filename);
       log.debug(
           "Loaded ["
               + jPunchProperties.size()
               + "] "
               + "properties from "
               + "["
               + filename
               + "]");
     } catch (FileNotFoundException e) {
       log.fatal("[" + filename + "] file not found", e);
       return null;
     } catch (IOException e) {
       log.fatal("I/O error reading file [" + filename + "]", e);
       return null;
     }
   }
   // if no properties in file
   if (jPunchProperties.size() == 0) {
     log.fatal("No properties in file [" + JPUNCH_PROPERTIES_FILE + "]");
     return null;
   }
   return jPunchProperties;
 }
예제 #10
0
  /**
   * Individua le annotations salvate ed esegue il salvataggio sul dao.
   *
   * @param cas CAS da elaborare
   * @throws AnalysisEngineProcessException errore nell'analisi del documento
   * @see JCasAnnotator_ImplBase#process(JCas)
   */
  public final void process(final JCas cas) throws AnalysisEngineProcessException {
    logger.debug("Start process - HpmAnnotator");

    String actionType = getActionTypeAnnotation(cas).getValue();

    try {
      //      nel caso di PROCESS.PATTERN.CREATE.ATTACHDOCUMENT associo gli
      //      attachments al pattern associato
      if (actionType.equals(PROCESS_PATTERN_CREATE_ATTACHDOCUMENT)) {
        processPatternAttachmentCas(cas);
      } else {
        processDefaultCas(cas);
      }
    } catch (Exception e) {

      logger.fatal("CAS non elaborata correttamente: ");
      logger.fatal("Salvataggio della cas " + cas.toString() + " su file");

      StringWriter sWriter = new StringWriter();
      e.printStackTrace(new PrintWriter(sWriter));
      logger.fatal(sWriter.getBuffer().toString());

      CasErrorManager cem = new CasErrorManager();
      cem.storeCasInFile(cas);

      throw new AnalysisEngineProcessException();
    }

    logger.debug("End process - HpmAnnotator");
  }
예제 #11
0
  private void initProperties(ITestContext context) {
    LOGGER.info("Initializing config.properties");
    PROPS = new Properties();
    try {
      WORKING_DIRECTORY = System.getProperty("user.dir");
      LOGGER.info("Working Directory = " + System.getProperty("user.dir"));
      try {
        String configFile = context.getCurrentXmlTest().getParameter(CONFIG_FILE_NAME);
        PROPS.load(new FileInputStream(configFile));
      } catch (NullPointerException e) {
        LOGGER.warn(
            "could not find the config file name in the xml suite, going to use the default "
                + CONFIG_FILE);
        try {
          String configFile = CONFIG_FILE;
          PROPS.load(new FileInputStream(configFile));
        } catch (NullPointerException e2) {
          LOGGER.fatal("could not find the default config file in the project");
        }
      }

    } catch (IOException e) {
      LOGGER.fatal("There was a problem to load the config file from " + CONFIG_FILE);
      e.printStackTrace();
    }
    VERSION = PROPS.getProperty(PROPERTIES.VERSION.name());
    PLATFORM = PROPS.getProperty(PROPERTIES.PLATFORM.name());
    BROWSER = PROPS.getProperty(PROPERTIES.BROWSER.name());
    LOCALE = PROPS.getProperty(PROPERTIES.LOCALE.name());
    SERVER = PROPS.getProperty(PROPERTIES.SERVER.name());
    LOGGER_LEVEL = PROPS.getProperty(PROPERTIES.LOGGER_LEVEL.name());
    LOGGER.info("Finished to initialize properties");
  }
예제 #12
0
파일: DeckUtil.java 프로젝트: xdaft/mage
 public static Deck construct(DeckView view) {
   Deck deck = new Deck();
   for (SimpleCardView cardView : view.getCards().values()) {
     CardInfo cardInfo =
         CardRepository.instance.findCard(
             cardView.getExpansionSetCode(), cardView.getCardNumber());
     Card card = cardInfo != null ? cardInfo.getCard() : null;
     if (card != null) {
       deck.getCards().add(card);
     } else {
       log.fatal(
           "(Deck constructing) Couldn't find card: set="
               + cardView.getExpansionSetCode()
               + ", cid="
               + Integer.valueOf(cardView.getCardNumber()));
     }
   }
   for (SimpleCardView cardView : view.getSideboard().values()) {
     CardInfo cardInfo =
         CardRepository.instance.findCard(
             cardView.getExpansionSetCode(), cardView.getCardNumber());
     Card card = cardInfo != null ? cardInfo.getCard() : null;
     if (card != null) {
       deck.getSideboard().add(card);
     } else {
       log.fatal(
           "(Deck constructing) Couldn't find card: set="
               + cardView.getExpansionSetCode()
               + ", cid="
               + Integer.valueOf(cardView.getCardNumber()));
     }
   }
   return deck;
 }
예제 #13
0
 public CompiledScriptCache loadCompiledScriptCache() {
   if (Config.SCRIPT_CACHE) {
     File file = new File(SCRIPT_FOLDER, "CompiledScripts.cache");
     if (file.isFile()) {
       ObjectInputStream ois = null;
       try {
         ois = new ObjectInputStream(new FileInputStream(file));
         CompiledScriptCache cache = (CompiledScriptCache) ois.readObject();
         return cache;
       } catch (InvalidClassException e) {
         _log.fatal(
             "Failed loading Compiled Scripts Cache, invalid class (Possibly outdated).", e);
       } catch (IOException e) {
         _log.fatal("Failed loading Compiled Scripts Cache from file.", e);
       } catch (ClassNotFoundException e) {
         _log.fatal("Failed loading Compiled Scripts Cache, class not found.", e);
       } finally {
         try {
           ois.close();
         } catch (Exception e) {
         }
       }
       return new CompiledScriptCache();
     } else return new CompiledScriptCache();
   }
   return null;
 }
  /** Responsible to set DWCA_USED_TERMS */
  @Override
  public void openReader(Map<SharedParameterEnum, Object> sharedParameters) {
    dwcaFilePath = (String) sharedParameters.get(SharedParameterEnum.DWCA_PATH);
    if (mapper == null) {
      throw new IllegalStateException("No mapper defined");
    }
    if (StringUtils.isBlank(dwcaFilePath)) {
      throw new IllegalStateException("sharedParameters missing: DWCA_PATH is required.");
    }

    File dwcaFile = new File(dwcaFilePath);
    Archive dwcArchive;
    try {
      dwcArchive = ArchiveFactory.openArchive(dwcaFile);
      prepareReader(dwcArchive.getCore());
    } catch (UnsupportedArchiveException e) {
      LOGGER.fatal("Can't open DwcaItemReader", e);
    } catch (IOException e) {
      LOGGER.fatal("Can't open DwcaItemReader", e);
    }

    // make sure those headers can be imported correctly
    validateDwcaHeaders();

    List<String> usedDwcTerms = new ArrayList<String>();
    usedDwcTerms.addAll(Arrays.asList(headers));
    if (defaultValues != null) {
      usedDwcTerms.addAll(defaultValues.keySet());
    }

    // set the used dwc terms used by this archive
    sharedParameters.put(SharedParameterEnum.DWCA_USED_TERMS, usedDwcTerms);
  }
  /**
   * 获取名称为dataSourceName的 DataSource.
   *
   * @param dataSourceName
   * @return
   * @throws SQLException
   */
  public DataSource getDataSource(String dataSourceName) throws SQLException {

    // 是否是已经获取的DataSource对象。
    DataSource ods = dataSourceMap.get(dataSourceName);
    if (ods != null) {
      return ods;
    }

    DataSource ds = null;
    //		1.从上下文根据JNDI获取DataSource
    Context initCtx = null;
    try {
      initCtx = new InitialContext(); // 创建上下文实例

      //			get DataSource by different Servlet Container Type.
      // Tomcat5 需要做特殊的处理
      Context envCtx = (Context) initCtx.lookup("java:comp/env");

      ds = (DataSource) envCtx.lookup(dataSourceName);
      dataSourceMap.put(dataSourceName, ds); // 缓存起来
      return ds;

    } catch (NamingException ex) {
      log.fatal("cant get the new InitialContext()");
      log.debug("debug", ex);
      /// ex.pri ntStackTrace();
      throw new SQLException(ex.getMessage());

    } catch (Exception ex) {
      log.fatal("cant get the new InitialContext()");
      log.debug("debug", ex);
      /// ex.pri ntStackTrace();
      throw new SQLException(ex.getMessage());
    }
  }
예제 #16
0
  /**
   * actual log statements
   *
   * @throws Exception
   */
  private void doLogging() throws Exception {
    // These messages with Level >= set level will be logged to
    // the database.
    logger.debug("debug DOM");
    // this not, because Priority DEBUG is less than INFO
    logger.info("info'test DOM");
    logger.error(
        "nested nullpointer error",
        new RemoteException("test", new RemoteException("test2", new NullPointerException())));
    logger.fatal("fatal DOM");

    // NDC/MDC
    logger.info(new Timestamp(1)); // object logging
    NDC.push("MyNDC");
    logger.info("info MyNDC");
    MDC.put("MyMDC", "MyMDC");
    MDC.put("MyMDC2", new Exception("MDC2").toString());
    logger.info("info MyNDC MyMDC");
    NDC.pop();
    logger.info("info MyMDC");

    // null tests
    logger.fatal(null);

    MDC.remove("MyMDC");
  }
예제 #17
0
  /** Sets up configuration based on params */
  private static boolean setup(Hashtable<String, String> curConf, Configuration argConf) {

    if (argConf.get("file") == null) {
      logger.fatal("Missing file parameter");
      System.exit(1);
    }

    if (argConf.get("hdfs_base_path") == null) {
      logger.fatal("Missing HDFS base path, check gestore-conf.xml");
      System.exit(1);
    }

    if (argConf.get("hdfs_temp_path") == null) {
      logger.fatal("Missing HDFS temp path, check gestore-conf.xml");
      System.exit(1);
    }

    if (argConf.get("local_temp_path") == null) {
      logger.fatal("Missing local temp path, check gestore-conf.xml");
      System.exit(1);
    }

    // Input paramaters
    curConf.put("run_id", argConf.get("run", ""));
    curConf.put("task_id", argConf.get("task", ""));
    curConf.put("file_id", argConf.get("file"));
    curConf.put("local_path", argConf.get("path", ""));
    curConf.put("type", argConf.get("type", "l2r"));
    curConf.put("timestamp_start", argConf.get("timestamp_start", "1"));
    curConf.put(
        "timestamp_stop", argConf.get("timestamp_stop", Integer.toString(Integer.MAX_VALUE)));
    curConf.put("delimiter", argConf.get("regex", "ID=.*"));
    curConf.put("taxon", argConf.get("taxon", "all"));
    curConf.put("intermediate", argConf.get("full_run", "false"));
    curConf.put("quick_add", argConf.get("quick_add", "false"));
    Boolean full_run = curConf.get("intermediate").matches("(?i).*true.*");
    curConf.put("format", argConf.get("format", "unknown"));
    curConf.put("split", argConf.get("split", "1"));
    curConf.put("copy", argConf.get("copy", "true"));

    // Constants
    curConf.put("base_path", argConf.get("hdfs_base_path"));
    curConf.put("temp_path", argConf.get("hdfs_temp_path"));
    curConf.put("local_temp_path", argConf.get("local_temp_path"));
    curConf.put("db_name_files", argConf.get("hbase_file_table"));
    curConf.put("db_name_runs", argConf.get("hbase_run_table"));
    curConf.put("db_name_updates", argConf.get("hbase_db_update_table"));

    // Timestamps
    Date currentTime = new Date();
    Date endDate = new Date(new Long(curConf.get("timestamp_stop")));
    curConf.put("timestamp_real", Long.toString(currentTime.getTime()));

    return true;
  }
예제 #18
0
  private void initParams(ITestContext context) {
    LOGGER.info("Initializing params.properties");
    PARAMS = new Properties();
    try {
      try {
        String paramsFile = context.getCurrentXmlTest().getParameter(PARAMS_FILE_NAME);
        PARAMS.load(new FileInputStream(paramsFile));
      } catch (NullPointerException e) {
        LOGGER.warn(
            "could not find the params file name in the xml suite, going to use the default "
                + PARAMS_FILE);
        try {
          String paramsFile = PARAMS_FILE;
          PARAMS.load(new FileInputStream(paramsFile));
        } catch (NullPointerException e2) {
          LOGGER.fatal("could not find the default params file in the project");
        }
      }

    } catch (IOException e) {
      LOGGER.fatal("There was a problem to load the config file from " + PARAMS_FILE);
      e.printStackTrace();
    }
    ADMIN_FILE_NAME = PARAMS.getProperty(ADMIN_PARAMS.ADMIN_FILE_NAME.name());
    USERS_FILE_NAME = PARAMS.getProperty(USER_PARAMS.USERS_FILE_NAME.name());
    TRANSACTIONS_FILE_NAME = PARAMS.getProperty(USER_PARAMS.TRANSACTIONS_FILE_NAME.name());
    CREDIT_CARDS_FILE_NAME = PARAMS.getProperty(CARD_PARAMS.CREDIT_CARDS_FILE_NAME.name());
    VERIFIES_FILE_NAME = PARAMS.getProperty(VERIFIES_PARAMS.VERIFIES_FILE_NAME.name());
    ACTIVATION_FILE_NAME = PARAMS.getProperty(VERIFIES_PARAMS.ACTIVATION_FILE_NAME.name());
    REGISTRATION_FILE_NAME = PARAMS.getProperty(VERIFIES_PARAMS.REGISTRATION_FILE_NAME.name());

    IMPLICITLY_WAIT_TIME =
        Integer.parseInt(PARAMS.getProperty(WAIT_TIME.IMPLICITLY_WAIT_TIME.name()));
    CORRECT_PAGE_WAIT_TIME =
        Integer.parseInt(PARAMS.getProperty(WAIT_TIME.CORRECT_PAGE_WAIT_TIME.name()));
    ELEMENT_WAIT_TIME = Integer.parseInt(PARAMS.getProperty(WAIT_TIME.ELEMENT_WAIT_TIME.name()));
    INITIALIZED_ELEMENT_WAIT_TIME =
        Integer.parseInt(PARAMS.getProperty(WAIT_TIME.INITIALIZED_ELEMENT_WAIT_TIME.name()));
    IFRAME_WAIT_TIME = Integer.parseInt(PARAMS.getProperty(WAIT_TIME.IFRAME_WAIT_TIME.name()));
    ADMIN_TAB_WAIT_TIME =
        Integer.parseInt(PARAMS.getProperty(WAIT_TIME.ADMIN_TAB_WAIT_TIME.name()));

    ADMIN_FILE_PATH = WORKING_DIRECTORY + "\\" + ADMIN_FILE_NAME;
    USERS_FILE_PATH = WORKING_DIRECTORY + "\\" + USERS_FILE_NAME;
    TRANSACTIONS_FILE_PATH = WORKING_DIRECTORY + "\\" + TRANSACTIONS_FILE_NAME;
    CREDIT_CARDS_FILE_PATH = WORKING_DIRECTORY + "\\" + CREDIT_CARDS_FILE_NAME;
    VERIFIES_FILE_PATH = WORKING_DIRECTORY + "\\" + VERIFIES_FILE_NAME;
    ACTIVATION_FILE_PATH = WORKING_DIRECTORY + "\\" + ACTIVATION_FILE_NAME;
    REGISTRATION_FILE_PATH = WORKING_DIRECTORY + "\\" + REGISTRATION_FILE_NAME;

    LOGGER.info("Finished to initialize parameters");
  }
 private void raiseJohnson(final StartupCheck failedCheck) {
   String desc = failedCheck.getFaultDescription();
   log.fatal(failedCheck.getName() + " failed: " + desc);
   log.fatal("Clustering startup check failed.");
   final EventType eventType;
   if (failedCheck instanceof ClusterLicenseCheck) {
     eventType = EventType.get(LicenseJohnsonEventRaiser.CLUSTERING_UNLICENSED);
   } else {
     eventType = EventType.get(LicenseJohnsonEventRaiser.CLUSTERING);
   }
   Event event =
       new Event(eventType, failedCheck.getHTMLFaultDescription(), EventLevel.get(ERROR));
   JohnsonEventContainer.get(servletContext).addEvent(event);
 }
예제 #20
0
 public void handleException(Exception ex) {
   if (ex != null) {
     logger.fatal(
         "User manager exception " + (ex.getMessage() == null ? "null" : ex.getMessage()));
     if (ex.getCause() != null) {
       logger.debug(
           "- Cause: "
               + (ex.getCause().getMessage() == null ? "null" : ex.getCause().getMessage()));
     }
     ex.printStackTrace();
   } else {
     logger.fatal("User manager exception - null");
   }
 }
예제 #21
0
 /** @param request */
 private void outRequestParam(HttpServletRequest request) {
   exceptionLogger.fatal(request.getQueryString());
   exceptionLogger.fatal(request.getServletPath());
   exceptionLogger.fatal(request.getRequestURL().toString());
   Map map = request.getParameterMap();
   exceptionLogger.info(map);
   Set set = map.keySet();
   Iterator iter = set.iterator();
   while (iter.hasNext()) {
     String key = (String) iter.next();
     exceptionLogger.fatal(key);
     exceptionLogger.fatal(getString(map.get(key)));
   }
 }
예제 #22
0
  private Config readConfig() {
    Config config = null;
    try {
      File file = new File("config.xml");
      JAXBContext jaxbContext = JAXBContext.newInstance(Config.class);
      Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
      config = (Config) jaxbUnmarshaller.unmarshal(file);
    } catch (JAXBException e) {
      log.fatal("Error reading config");
      log.fatal(e.getMessage());
    }

    return config;
  }
  private int doQuery(FuncCatePath category, FuncVP fvp) {

    logger.fatal(
        String.format(
            " - [LOG_SUMMARY] - categoryname: %s, query: %s",
            category.getFcate_name() + category.getCat_path(), category.getQuery()));
    Map<String, String> infop = URLBuilder.l_getPreSearchInfo(category.getCat_path()); // 获取默认的查询内容
    infop.put("catename", category.getFcate_name());
    infop.put("cat_paths", category.getCat_path());
    infop.put("cat_query", category.getQuery());
    logger.fatal(" - [LOG_SUMMARY] - preSearchInfo: " + infop.toString());

    Map<String, String> urlp = URLBuilder.converURLPars(fvp.getFvp(), category.getQuery(), infop);
    ProdIterator s_iterator = new ProdIterator(urlp);

    Map<String, String> l_urlp =
        URLBuilder.l_converURLPars(fvp.getFvp(), category.getCat_path(), infop);
    ProdIterator l_iterator = new ProdIterator(l_urlp);

    if (l_iterator.getTotalCount() < 1 || s_iterator.getTotalCount() < 1) {
      logger.fatal(
          String.format(
              " - [LOG_SKIP] - no result:categoryname: %s, query: %s",
              category.getFcate_name() + category.getCat_path(), category.getQuery()));
      return -2;
    }

    if (doVerify(l_iterator, s_iterator, fvp, infop)) {
      logger.fatal(
          " - [LOG_SUCCESS] - verify function 【"
              + fvp.getFvpname()
              + "】 for category: "
              + category.getFcate_name()
              + category.getCat_path()
              + "query:"
              + category.getQuery());
      return 0;
    } else {
      logger.error(
          " - [LOG_FAILED] - verify function 【"
              + fvp.getFvpname()
              + "】 for category: "
              + category.getFcate_name()
              + category.getCat_path()
              + "query:"
              + category.getQuery());
      return -1;
    }
  }
예제 #24
0
 public static void useScreenMenuBar() {
   try {
     System.setProperty("apple.laf.useScreenMenuBar", "true");
     System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Application L.L.L.");
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (ClassNotFoundException e) {
     logger.fatal("ClassNotFoundException: " + e.getMessage());
   } catch (InstantiationException e) {
     logger.fatal("InstantiationException: " + e.getMessage());
   } catch (IllegalAccessException e) {
     logger.fatal("IllegalAccessException: " + e.getMessage());
   } catch (UnsupportedLookAndFeelException e) {
     logger.fatal("UnsupportedLookAndFeelException: " + e.getMessage());
   }
 }
 private boolean checkInputPath() {
   if (!(new File(conf.getInputProjectPath()).exists())) {
     log.fatal("The input path " + conf.getInputProjectPath() + " can't be accessed.");
     return false;
   }
   if (!(new File(conf.getInputProjectPath() + conf.getInputProjectSrcPath()).exists())) {
     log.fatal("The input source path " + conf.getInputProjectSrcPath() + " can't be accessed.");
     return false;
   }
   if (!(new File(conf.getInputProjectPath() + conf.getInputProjectTestPath()).exists())) {
     log.fatal("The input test path " + conf.getInputProjectTestPath() + " can't be accessed.");
     return false;
   }
   return true;
 }
  @Test(enabled = false, groups = "p2") // 目前测试环境没有该功能代码
  public void category_and_query() {
    long d = System.currentTimeMillis();
    DBAction dba = new DBAction();
    dba.setFuncCondition("module = 'q_and_c'");
    dba.setFvpCondition("fvp_id = 29");
    List<FuncCatePath> categorys = dba.getFuncCatePath();
    List<FuncVP> fvps = dba.getFVP();
    String subject = "【搜索后台自动化测试】基础功能回归测试结果";
    StringBuffer content = new StringBuffer();
    content.append(
        "<html><head><meta http-equiv=Content-Type content='text/html; charset=utf-8'></head><body><table border=1 cellspacing=0 cellpadding=0><tr><th>功能模块</th><th>通过category</th><th>失败category</th><th>跳过category</th><th>总计</th><th>耗时</th></tr>");
    for (FuncVP fvp : fvps) {
      int passed = 0, failed = 0, skiped = 0;
      for (FuncCatePath category : categorys) {
        int rt = doQuery(category, fvp);
        switch (rt) {
          case 0:
            passed += 1;
            break;
          case -1:
            failed += 1;
            break;
          case -2:
            skiped += 1;
            break;

          default:
            failed += 1;
            break;
        }
      }
      logger.fatal(
          String.format(
              " - [LOG_SUMMARY] - vp: %s, passed: %s, failed: %s, skiped: %s",
              fvp.getFvpname(), passed, failed, skiped));
      long d2 = System.currentTimeMillis();
      int d4 = (int) ((d2 - d) / 60000 + 1);
      logger.fatal("总耗时:" + d4 + "分钟");
      String d3 = String.valueOf(d4) + "分钟";
      content.append(
          String.format(
              "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",
              fvp.getFvpname(), passed, failed, skiped, passed + failed + skiped, d3));
    }
    content.append("</table></body></html>");
    Utils.sendMail(subject, content.toString(), "HTML");
  }
  private void getAgentIcons() {
    try {
      RandomAccessFile participantsFile =
          new RandomAccessFile(
              Simulator.inputFoldersPath + Simulator.inputFolder + "/participants.csv", "r");
      participantsFile.readLine();

      String currentLine = participantsFile.readLine();

      // Set the System Data
      while (!(currentLine == null)) {
        String[] theArgs = StringParseTools.readTokens(currentLine, ",");

        if (theArgs[2].contains("<player>")) {
          try {
            agentIcons.put(theArgs[1], convert(ImageIO.read(new File("images/" + theArgs[3]))));
          } catch (Exception e) {
            logger.warn(
                "Couldn't find the icon file 'images/"
                    + theArgs[3]
                    + "' for agent '"
                    + theArgs[1]
                    + "'.");
          }
        }

        // get next line
        currentLine = participantsFile.readLine();
      }
      participantsFile.close();
    } catch (Exception e) {
      logger.fatal("Error access System I/O file: ", e);
    }
  }
 /**
  * Copies data from input stream to output stream. Also matches for the log snippet and marks the
  * process state started if found.
  */
 @Override
 public void run() {
   final String newLine = System.getProperty("line.separator", "\n");
   String line;
   try {
     while ((line = reader.readLine()) != null) {
       System.out.println(line);
       line += newLine;
       if (!isStarted && logSnippet != null) {
         if (line.toLowerCase().indexOf(logSnippet.toLowerCase()) >= 0
             || logSnippet.trim().length() == 0) {
           isStarted = true;
           log.debug("Process marked STARTED.");
           state.markStarted();
         }
       }
       out.write(line.getBytes());
       out.flush();
     }
   } catch (IOException ioe) {
     log.fatal("Probably process exited abnormally: " + ioe.getMessage());
   } finally {
     IOUtils.closeQuietly(reader);
   }
 }
  public static boolean waitForInstellationToFinish(
      String installationStatus, int timeout, String commandParam, ExecuteWindowsCommands command) {
    boolean success = false;
    try {
      while (totalTimeout > timeout) {
        if (installationStatus.contains("RUNNING")) {
          success = true;
          System.out.println(SUCCESS_MESSAGE);
          logger.info(SUCCESS_MESSAGE);
          break;
        } else {

          TimeUnit.SECONDS.sleep(timeout);
          timeout = timeout + 60;
          logger.warn(WARNING_MESSAGE);
          System.out.println(WARNING_MESSAGE);
          installationStatus = command.anyCMDCommandLocally(commandParam);
        }
      }
    } catch (InterruptedException e) {
      logger.warn(WARNING_MESSAGE + e.getMessage());
    }
    if (timeout > totalTimeout && (!installationStatus.contains("RUNNING"))) {
      ERROR_MESSAGE_TC = "It was Not Possible to Install Agent";
      logger.fatal(ERROR_MESSAGE_TC);
      System.out.println(ERROR_MESSAGE_TC);
    }
    return success;
  }
예제 #30
0
  /**
   * Set up and run a test suite
   *
   * @param suite
   * @param testInputProv
   * @param resultMgr
   * @param reporter
   * @throws Exception
   */
  private static boolean setUpAndRunTestSuite(
      TestSuiteInfo suite,
      ITRTestInputProvider testInputProv,
      ITRTestOutputManager resultMgr,
      IReportFacade reporter) {
    final String component = suite.getComponent();
    List<ITestCaseDescriptor> testCases = null;

    // Setup the test suite
    // TODO: Move the suite setup to org.splandroid.tr.testing pkg?
    reporter.startingTestSuiteSetUp(component);
    try {
      testCases = setUpTestSuite(suite, testInputProv, resultMgr);
      removeTestCases(suite, testCases);
    } catch (Exception ex) {
      logger.fatal(
          String.format(
              "Processing of test suite set-up for component [%s] failed: %s",
              component, ex.getMessage()),
          ex);
      reporter.errorTestSuiteSetUp(component, ex);
      return false;
    }
    reporter.finishedTestSuiteSetUp(component);

    // Run the test suite
    final boolean passed = runTestSuite(component, testCases, testInputProv, resultMgr, reporter);

    logger.info(String.format("Finished test suite for [%s]", component));

    return passed;
  }