示例#1
1
 /** 配置处理器 */
 public void configHandler(Handlers me) {
   logger.info("配置处理器开始..");
   me.add(new ContextPathHandler("base"));
   DruidStatViewHandler dsvh = new DruidStatViewHandler("/druid");
   me.add(dsvh);
   logger.info("配置处理器结束..");
 }
示例#2
1
 /** 配置插件 */
 public void configPlugin(Plugins me) {
   logger.info("配置插件开始..");
   DruidPlugin dp =
       new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password"));
   WallFilter wf = new WallFilter();
   wf.setDbType("mysql");
   dp.addFilter(wf);
   me.add(dp);
   // 配置Ecache插件
   me.add(new EhCachePlugin());
   // 配置ActiveRecord插件
   ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
   me.add(arp);
   arp.setDevMode(true);
   arp.setShowSql(true);
   // 此项目并没有用到jfinal2.2的javabean与model的合体,感兴趣的可以参照jfinal官网的demo
   arp.addMapping("blog", Blog.class); // 映射blog 表到 Blog模型
   arp.addMapping("user", User.class); // 用户
   arp.addMapping("qquser", Qquser.class); // qq用户
   arp.addMapping("blogcategory", Blogcategory.class); // 博客分类
   arp.addMapping("userlogininfo", Userlogininfo.class); // 用户登陆信息
   arp.addMapping("advice", Advice.class); // 建议
   arp.addMapping("role", Role.class); // 角色
   arp.addMapping("userrole", Userrole.class); // 用户角色中间表
   arp.addMapping("picrecommend", Picrecommend.class); // 首页图片推荐--推荐尺寸为630*350
   arp.addMapping("beauty", Beauty.class); // 美图
   arp.addMapping("gonggao", Gonggao.class); // 公告
   arp.addMapping("iplog", Iplog.class); // ip和URL日志
   arp.addMapping("video", Video.class); // 视频模块
   arp.addMapping("resourceslog", Resourceslog.class); // 系统资源监控日志
   arp.addMapping("link", Link.class); // 友情链接
   logger.info("配置插件结束..");
 }
示例#3
0
  /**
   * @param file - the file to delete
   * @param deleteEmptyParents - removing empty parent folders flag
   * @param rootPath - if deleteEmptyParents is true, this parameters shows the parent folder where
   *     removing parents must stop
   * @return True, if the file has been successfully removed, otherwise returns false
   */
  public static boolean delete(File file, boolean deleteEmptyParents, String rootPath) {
    log.info("M-DELETE file: " + file);
    if (!file.exists()) {
      File rootFile = rootPath == null ? null : toFile(rootPath);
      boolean isParentReliable = isReliable(file.getParentFile(), rootFile);

      log.warn(
          format(
              isParentReliable
                  ? "File [%s] has already been deleted."
                  : "Cannot list file [%s]; is its parent-directory tree mounted and executable?",
              file));

      return isParentReliable;
    }
    if (!file.delete()) {
      log.warn("Failed to delete file: " + file);
      return false;
    }
    if (deleteEmptyParents) {
      File parentToKeep = null;
      if (rootPath != null) parentToKeep = toFile(rootPath);

      File parent = file.getParentFile();
      while (!parent.equals(parentToKeep) && parent.delete()) {
        log.info("M-DELETE directory: " + parent);
        parent = parent.getParentFile();
      }
    }
    return true;
  }
示例#4
0
  /** 主方法 如果某方法可被缓存就缓存其结果 方法结果必须是可序列化的(serializable) */
  public Object invoke(MethodInvocation invocation) throws Throwable {

    String targetName = invocation.getThis().getClass().getName();

    String methodName = invocation.getMethod().getName();

    Object[] arguments = invocation.getArguments();

    Object result;

    logger.info("在缓存中查找方法返回的对象!");

    String cacheKey = getCacheKey(targetName, methodName, arguments);

    Element element = cache.get(cacheKey);

    if (element == null) {

      logger.info("正在拦截方法!");

      result = invocation.proceed();

      logger.info("正在缓存对象!");

      element = new Element(cacheKey, (Serializable) result);

      cache.put(element);
    }

    return element.getValue();
  }
示例#5
0
 // @AfterSuite
 public void resetEnv() {
   if (driver != null) {
     driver.quit();
     log.info("Browser close successful");
   }
   log.info("Tests Suite execution completed.");
 }
示例#6
0
 public Collection getAllRateCodes(int tdspId) {
   /**
    * Requires - Modifies - Effects -
    *
    * @throws -
    */
   Criteria objCriteria = null;
   Session objSession = null;
   List objList = null;
   try {
     logger.info("GETTING ALL RATE CODES BY TDSP ID");
     objSession = HibernateUtil.getSession();
     objCriteria =
         objSession
             .createCriteria(RateCodesVO.class)
             .add(Restrictions.eq("tdsp.tdspIdentifier", new Integer(tdspId)));
     objCriteria.addOrder(Order.asc("rateCode"));
     objList = objCriteria.list();
     logger.info("GOT ALL RATE CODES BY TDSP ID");
   } catch (HibernateException e) {
     logger.error("HIBERNATE EXCEPTION DURING GET ALL RATE CODES BY TDSP ID", e);
     e.printStackTrace();
   } finally {
     if (objSession != null) {
       objSession.close();
     }
   }
   return objList;
 }
示例#7
0
 /** 配置全局拦截器 */
 public void configInterceptor(Interceptors me) {
   logger.info("配置全局拦截器开始..");
   me.addGlobalActionInterceptor(new PhoneInterceptor());
   me.addGlobalActionInterceptor(new LogInterceptor());
   me.add(new TxByMethodRegex("(.*save.*|.*update.*|.*delete.*)")); // 2.2改动
   logger.info("配置全局拦截器结束..");
 }
示例#8
0
  /**
   * Ingest.
   *
   * @param foxml the foxml
   * @param label the label
   * @param uuid the uuid
   * @param model the model
   * @param topLevelUuid the top level uuid
   * @param inputDirPath the input dir path
   * @return true, if successful
   */
  public static boolean ingest(
      String foxml,
      String label,
      String uuid,
      String model,
      String topLevelUuid,
      String inputDirPath) {

    if (uuid != null && !uuid.startsWith(Constants.FEDORA_UUID_PREFIX)) {
      uuid = Constants.FEDORA_UUID_PREFIX + uuid;
    }

    if (LOGGER.isInfoEnabled()) {
      LOGGER.info(
          "Ingesting the digital object with PID"
              + (!uuid.contains("uuid:") ? " uuid:" : " ")
              + uuid
              + " label:"
              + label
              + ", model: "
              + model);
    }

    String login = config.getFedoraLogin();
    String password = config.getFedoraPassword();
    String url = config.getFedoraHost() + "/objects/new";
    boolean success = RESTHelper.post(url, foxml, login, password, false);

    if (LOGGER.isInfoEnabled() && success) {
      LOGGER.info("Object ingested -- uuid:" + uuid + " label: " + label + ", model: " + model);
    }

    if (topLevelUuid != null && inputDirPath != null && INGEST_LOGGER.isInfoEnabled()) {
      INGEST_LOGGER.info(String.format("%s %16s %s", uuid, model, label));
    }
    if (success) {
      if (topLevelUuid != null && inputDirPath != null) {
        try {
          if (!uuid.equals(topLevelUuid)) {
            // TODO-MR
            //                        digitalObjectDAO.insertNewDigitalObject(uuid,
            //                                                                model,
            //                                                                label,
            //                                                                inputDirPath,
            //                                                                topLevelUuid,
            //                                                                false);
          } else {
            digitalObjectDAO.updateTopObjectTime(uuid);
          }
        } catch (DatabaseException e) {
          LOGGER.error("DB ERROR!!!: " + e.getMessage() + ": " + e);
          e.printStackTrace();
        }
      }
    } else {
      LOGGER.error(
          "Unable to ingest object uuid:" + uuid + " label: " + label + ", model: " + model);
    }
    return success;
  }
示例#9
0
  private static void handleExportAttributesFromJAR(Element e, File config, File toDir) {
    for (Element c : ((List<Element>) e.getChildren()).toArray(new Element[0])) {
      Attribute a = c.getAttribute("EXPORT");
      if (a != null && a.getValue().equals("copy")) {
        /* Copy file from JAR */
        File file = GUI.restoreConfigRelativePath(config, new File(c.getText()));
        InputStream inputStream = GUI.class.getResourceAsStream("/" + file.getName());
        if (inputStream == null) {
          throw new RuntimeException("Could not unpack file: " + file);
        }
        byte[] fileData = ArrayUtils.readFromStream(inputStream);
        if (fileData == null) {
          logger.info("Failed unpacking file");
          throw new RuntimeException("Could not unpack file: " + file);
        }
        if (OVERWRITE || !file.exists()) {
          boolean ok = ArrayUtils.writeToFile(file, fileData);
          if (!ok) {
            throw new RuntimeException("Failed unpacking file: " + file);
          }
          logger.info("Unpacked file from JAR: " + file.getName());
        } else if (OVERWRITE) {
          logger.info("Skip: unpack file from JAR: " + file.getName());
        }
      }

      /* Recursive search */
      handleExportAttributesFromJAR(c, config, toDir);
    }
  }
示例#10
0
  /**
   * 购买福利-生成订单
   *
   * @author zhliu
   * @date 2015年6月19日
   * @parm
   * @param request
   * @param response
   * @param packageId : 套餐ID
   * @param count
   * @return
   */
  @RequestMapping("/buyWelfareOrder")
  public String buyWelfareOrder(HttpServletRequest request, RequestBookingOrder bookingOrder) {

    Order order = new Order();

    try {
      User user = (User) request.getSession().getAttribute(SecurityConstants.SESSION_USER);
      bookingOrder.setUserId(user.getObjectId());
      bookingOrder.setOrderType(IBSConstants.ORDER_TYPE_POINT_BUY); // 积分购买
      bookingOrder.setOrderSource(IBSConstants.ORDER_SOURCE_HR); // 企业HR端
      //    		bookingOrder.setOrderProductType(IBSConstants.ORDER_PRODUCT_TYPE_WELFARE);//订单商品类型
      // 1福利套餐,2体检套餐,3SKU商品,4生活服务
      bookingOrder.setUserId(user.getObjectId());

      logger.info("HR端购买福利 --购买福利---开始");
      order = orderManager.createImmediateOrder(bookingOrder);
      logger.info("HR端购买福利 --购买福利---结束");
    } catch (Exception e) {
      logger.error("HR端购买福利 出错了,抛异常信息...", e);
      if (e.getMessage().equals("商品库存不足")) {
        request.setAttribute("msg", e.getMessage());
      } else {
        request.setAttribute("msg", "预定失败");
      }
      return HOME_DIR + "/bookOrderFail";
    }

    return "redirect:" + "buyWelfareOrderSuc/" + order.getObjectId();
  }
示例#11
0
  /**
   * 购买商品-生成订单
   *
   * @author zhliu
   * @date 2015年6月19日
   * @parm
   * @param request
   * @param response
   * @param packageId : 套餐ID
   * @param count
   * @return
   */
  @RequestMapping("/buyProdOrder")
  public String buyProdOrder(HttpServletRequest request, RequestBookingOrder bookingOrder) {

    Order order = new Order();

    try {
      User user = (User) request.getSession().getAttribute(SecurityConstants.SESSION_USER);

      bookingOrder.setUserId(user.getObjectId());
      bookingOrder.setOrderType(IBSConstants.ORDER_TYPE_POINT_BUY); // 年度福利
      bookingOrder.setOrderSource(IBSConstants.ORDER_SOURCE_HR); // 企业HR端
      bookingOrder.setOrderProductType(
          IBSConstants.ORDER_PRODUCT_TYPE_WELFARE); // 订单商品类型  1福利套餐,2体检套餐,3SKU商品,4生活服务
      bookingOrder.setUserId(user.getObjectId());

      logger.info("HR端购买福利 --购买商品---开始");
      order = orderManager.createImmediateOrder(bookingOrder);
      logger.info("HR端购买福利 --购买商品---结束");
    } catch (Exception e) {
      e.printStackTrace();
      logger.error("HR端购买福利 --购买商品---失败");
      logger.error(e.getMessage());
    }

    return "redirect:" + "buyWelfareOrderSuc/" + order.getObjectId();
  }
  @GET
  @Path(GET_USER_CHARACTERS)
  @Produces(MediaType.APPLICATION_JSON)
  @Override
  public ServiceResponse<List<PlayerCharacter>> getUserCharacters(
      @QueryParam("user") String username) {
    long requestReceived = System.currentTimeMillis();
    ServiceResponse<List<PlayerCharacter>> response = new ServiceResponse<List<PlayerCharacter>>();
    CharacterFetchingProcessor proc =
        (CharacterFetchingProcessor)
            SpringContextAware.getSpringBeanFromContext(CharacterFetchingProcessor.class);

    LOGGER.info(GET_USER_CHARACTERS + " request for " + username);

    try {
      response.setResponse(proc.processUserCharacterFetchRequest(username));
      response.setStatus(RESULT_SUCCESS);
    } catch (Exception e) {
      response.setMessage(e.getMessage());
      response.setStatus(RESULT_FAIL);
    } finally {
      response.setVersion(VERSION);
      response.setResponseTime(System.currentTimeMillis() - requestReceived);
      response.setReferenceNumber(username + "-" + requestReceived);

      LOGGER.info(response.toString());
    }

    return response;
  }
示例#13
0
  public int predictState(int from_state, int number_of_steps) {
    long lStartTime = System.currentTimeMillis();
    int from_bin = getBinNumber((float) from_state);
    SimpleMatrix result = new SimpleMatrix(transition_matrix);
    for (int i = 1; i < number_of_steps; i++) result = result.mult(transition_matrix);

    SimpleMatrix row_result = result.extractVector(true, from_bin);
    //			row_result.print();

    double maxVal = row_result.get(0, 0);
    int maxValIndex = 0;
    for (int i = 1; i < row_result.numCols(); i++) {
      if (row_result.get(0, i) >= maxVal) {
        maxVal = row_result.get(0, i);
        maxValIndex = i;
      }
    }
    long lEndTime = System.currentTimeMillis();
    logger.info(
        ("From: "
            + from_state
            + " In NumberOfSteps: "
            + number_of_steps
            + " MaxProbabilityBin: "
            + maxValIndex
            + "  MostProbablyTo: "
            + getOrgValFromBinNumber(maxValIndex)));
    logger.info(("Time taken for prediction = " + (lEndTime - lStartTime)));
    return getOrgValFromBinNumber(maxValIndex);
  }
  @POST
  @Path(ADD_ATTACK_MODE)
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  @Override
  public ServiceNullResponse addAttackMode(ServiceRequest<AttackMode> request) {
    long requestReceived = System.currentTimeMillis();
    ServiceNullResponse response = new ServiceNullResponse();
    CharacterProcessor proc =
        (CharacterProcessor) SpringContextAware.getSpringBeanFromContext(CharacterProcessor.class);

    LOGGER.info(request.toString());

    try {
      if (proc.processAddAttackModeRequest(request.getRequest()))
        response.setStatus(RESULT_SUCCESS);
      else response.setStatus(RESULT_FAIL);
    } catch (Exception e) {
      response.setMessage(e.getMessage());
      response.setStatus(RESULT_FAIL);
    } finally {
      response.setVersion(VERSION);
      response.setResponseTime(System.currentTimeMillis() - requestReceived);
      response.setReferenceNumber(request.getReferenceNumber());

      LOGGER.info(response.toString());
    }

    return response;
  }
  @GET
  @Path(GET_CHARACTER_ATTACK_MODES)
  @Produces(MediaType.APPLICATION_JSON)
  @Override
  public ServiceResponse<List<AttackMode>> getCharacterAttackModes(
      @QueryParam("id") long characterId) {
    long requestReceived = System.currentTimeMillis();
    ServiceResponse<List<AttackMode>> response = new ServiceResponse<List<AttackMode>>();
    CharacterFetchingProcessor proc =
        (CharacterFetchingProcessor)
            SpringContextAware.getSpringBeanFromContext(CharacterFetchingProcessor.class);

    LOGGER.info(
        GET_CHARACTER_ATTACK_MODES
            + " request received for "
            + characterId
            + " - "
            + requestReceived);

    try {
      response.setResponse(proc.processGetCharacterAttackModesRequest(characterId));
      response.setStatus(RESULT_SUCCESS);
    } catch (Exception e) {
      response.setMessage(e.getMessage());
      response.setStatus(RESULT_FAIL);
    } finally {
      response.setVersion(VERSION);
      response.setResponseTime(System.currentTimeMillis() - requestReceived);
      response.setReferenceNumber(Long.toString(requestReceived));

      LOGGER.info(response.toString());
    }

    return response;
  }
  @GET
  @Path(GET_FEATS)
  @Produces(MediaType.APPLICATION_JSON)
  @Override
  public ServiceResponse<List<Feat>> getAllFeats() {
    long requestReceived = System.currentTimeMillis();
    ServiceResponse<List<Feat>> response = new ServiceResponse<List<Feat>>();
    CharacterFetchingProcessor proc =
        (CharacterFetchingProcessor)
            SpringContextAware.getSpringBeanFromContext(CharacterFetchingProcessor.class);

    LOGGER.info(GET_FEATS + " request received - " + requestReceived);

    try {
      response.setResponse(proc.processGetAllFeatsRequest());
      response.setStatus(RESULT_SUCCESS);
    } catch (Exception e) {
      response.setMessage(e.getMessage());
      response.setStatus(RESULT_FAIL);
    } finally {
      response.setVersion(VERSION);
      response.setResponseTime(System.currentTimeMillis() - requestReceived);
      response.setReferenceNumber(Long.toString(requestReceived));

      LOGGER.info(response.toString());
    }

    return response;
  }
示例#17
0
  @Test
  public void testRestart() throws Exception {
    // Start Server getInstance
    Main.main(new String[] {});

    log.info("\n\n\nWait for restart\n\n\n");
    Thread.sleep(5000);
    Main.restart();

    log.info("\n\n\nWait for two immediately restarts\n\n\n");
    Thread.sleep(5000);
    Main.restart();
    Main.restart();

    log.info("\n\n\nWait for concurent restarts\n\n\n");
    Thread.sleep(5000);
    for (int i = 0; i < 5; i++) {
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  Main.restart();
                }
              })
          .start();
    }
  }
  public static void backSearchKeyWord() {
    Session sessionBase = HibernateCountUtil.currentSession();
    Connection countCon = getCountJDBCCon();
    try {
      countCon.setAutoCommit(false);
      long b = new Date().getTime();
      backAllByPage(sessionBase, countCon);
      // 备份每个月的数据
      countCon.commit();
      logger.info("备份事务提交");
      logger.info("关键字日志备份初始化完成,耗时【" + (new Date().getTime() - b) + "】毫秒");

    } catch (SQLException e) {
      try {
        countCon.rollback();
      } catch (SQLException e1) {
        logger.error(e1.getMessage(), e1);
      }
      logger.error(e.getMessage(), e);
    } finally {
      try {
        countCon.close();
      } catch (SQLException e) {
        logger.error(e.getMessage(), e);
      }
    }
  }
示例#19
0
  private <T> T scaleImageUsingAffineTransformation(final BufferedImage bufferedImage, T target) {
    BufferedImage destinationImage = generateDestinationImage();
    Graphics2D graphics2D = destinationImage.createGraphics();
    AffineTransform transformation =
        AffineTransform.getScaleInstance(
            ((double) getQualifiedWidth() / bufferedImage.getWidth()),
            ((double) getQualifiedHeight() / bufferedImage.getHeight()));
    graphics2D.drawRenderedImage(bufferedImage, transformation);
    graphics2D.addRenderingHints(retrieveRenderingHints());
    try {
      if (target instanceof File) {
        LOGGER.info(String.format(M_TARGET_TYPE_OF, "File"));
        ImageIO.write(destinationImage, imageType.toString(), (File) target);
      } else if (target instanceof ImageOutputStream) {
        LOGGER.info(String.format(M_TARGET_TYPE_OF, "ImageOutputStream"));
        ImageIO.write(destinationImage, imageType.toString(), (ImageOutputStream) target);
      } else if (target instanceof OutputStream) {
        LOGGER.info(String.format(M_TARGET_TYPE_OF, "OutputStream"));
        ImageIO.write(destinationImage, imageType.toString(), (OutputStream) target);
      } else {
        target = null;
      }
    } catch (IOException e) {
      e.printStackTrace();
    }

    return target;
  }
示例#20
0
  void addListener(
      Object listener, PropertyKey propertyKey, ChangeType changeType, EventType[] eventType) {
    checkConnected();

    PropertyType type = propertyKey.getType();

    synchronized (this) {
      for (CallbackHandler handler : _handlers) {
        // compare property-key path and listener reference
        if (handler.getPath().equals(propertyKey.getPath())
            && handler.getListener().equals(listener)) {
          LOG.info(
              "Listener: "
                  + listener
                  + " on path: "
                  + propertyKey.getPath()
                  + " already exists. skip add");

          return;
        }
      }

      CallbackHandler newHandler =
          new CallbackHandler(this, _zkclient, propertyKey, listener, eventType, changeType);

      _handlers.add(newHandler);
      LOG.info(
          "Added listener: "
              + listener
              + " for type: "
              + type
              + " to path: "
              + newHandler.getPath());
    }
  }
  @Override
  public void launchTask(final ExecutorDriver executorDriver, final Protos.TaskInfo taskInfo) {
    LOGGER.info("Launching task in PinUserProfileExecutor ...");
    Protos.TaskStatus taskStatus =
        Protos.TaskStatus.newBuilder()
            .setTaskId(taskInfo.getTaskId())
            .setState(Protos.TaskState.TASK_RUNNING)
            .build();
    executorDriver.sendStatusUpdate(taskStatus);
    String url = taskInfo.getData().toStringUtf8();
    byte[] message = new byte[0];

    try {
      message = ("userprofile :" + getUserProfileInfo(url)).getBytes();
    } catch (IOException e) {
      LOGGER.error("Error parsing the Pinterest URL :" + e.getMessage());
    }

    LOGGER.info("Sending framework message and marking task finished." + getClass().getName());
    executorDriver.sendFrameworkMessage(message);

    taskStatus =
        Protos.TaskStatus.newBuilder()
            .setTaskId(taskInfo.getTaskId())
            .setState(Protos.TaskState.TASK_FINISHED)
            .build();
    executorDriver.sendStatusUpdate(taskStatus);
  }
示例#22
0
  @Override
  public void disconnect() {
    if (_zkclient == null) {
      LOG.info("instanceName: " + _instanceName + " already disconnected");
      return;
    }

    LOG.info("disconnect " + _instanceName + "(" + _instanceType + ") from " + _clusterName);

    try {
      /** stop all timer tasks */
      stopTimerTasks();

      /**
       * shutdown thread pool first to avoid reset() being invoked in the middle of state transition
       */
      _messagingService.getExecutor().shutdown();

      // TODO reset user defined handlers only
      resetHandlers();

      _dataAccessor.shutdown();

      if (_leaderElectionHandler != null) {
        _leaderElectionHandler.reset();
      }

    } finally {
      _zkclient.close();
      _zkclient = null;
      LOG.info("Cluster manager: " + _instanceName + " disconnected");
    }
  }
示例#23
0
 public HashMap getAllRateCodes() {
   /**
    * Requires - Modifies - Effects -
    *
    * @throws -
    */
   Criteria objCriteria = null;
   Session objSession = null;
   Integer totRecordCount = null;
   List objList = null;
   HashMap hmResult = new HashMap();
   try {
     logger.info("GETTING ALL RATE CODES");
     objSession = HibernateUtil.getSession();
     objCriteria = objSession.createCriteria(RateCodesVO.class);
     totRecordCount = new Integer(objCriteria.list().size());
     objList = objCriteria.list();
     hmResult.put("TotalRecordCount", totRecordCount);
     hmResult.put("Records", objList);
     logger.info("GOT ALL RATE CODES");
   } catch (HibernateException e) {
     logger.error("HIBERNATE EXCEPTION DURING GET ALL RATE CODES", e);
     e.printStackTrace();
   } finally {
     if (objSession != null) {
       objSession.close();
     }
   }
   return hmResult;
 }
示例#24
0
 @Override
 public void afterJFinalStart() {
   logger.info("afterJFinalStart开始..");
   // 公告
   List<Gonggao> listGonggao = Gonggao.me.listAll();
   JFinal.me().getServletContext().setAttribute("gonggao", listGonggao);
   // 全局博客分类
   List<Blogcategory> listBlogcategory = Blogcategory.me.listAll();
   com.fly.common.Constants.setListBlogcategory(listBlogcategory);
   JFinal.me().getServletContext().setAttribute("cloudcategory", listBlogcategory);
   // 友情链接
   List<Link> listLink = Link.me.listAll();
   JFinal.me().getServletContext().setAttribute("systemListLink", listLink);
   // 网站域名
   JFinal.me().getServletContext().setAttribute("siteUrl", PropKit.get("siteUrl"));
   // 网站名称
   JFinal.me().getServletContext().setAttribute("siteName", PropKit.get("siteName"));
   // 多少插件短地址,注册时候的端地址,需自己注册,在配置文件中修改,默认写的是test
   JFinal.me()
       .getServletContext()
       .setAttribute("duoshuoShortName", PropKit.get("duoshuoShortName"));
   // 是否开放注册
   JFinal.me()
       .getServletContext()
       .setAttribute("systemRegisterOpen", PropKit.get("systemRegisterOpen"));
   // 是否开放普通用户写博客,传美图,发视频
   JFinal.me().getServletContext().setAttribute("systemEditOpen", PropKit.get("systemEditOpen"));
   TimerResourcesLog.start();
   // 定时器(目前主要是每天定时清理资源日志,一天有720条资源日志,每天凌晨2点清理一周前的日志,可自己修改时间)
   TimerManager tm = new TimerManager();
   tm.init();
   logger.info("afterJFinalStart结束..");
 }
示例#25
0
  public final void createPersonQuadTree() {
    log.info("TEST");
    double minx = (1.0D / 0.0D);
    double miny = (1.0D / 0.0D);
    double maxx = (-1.0D / 0.0D);
    double maxy = (-1.0D / 0.0D);

    for (ActivityFacility f : this.scenario.getActivityFacilities().getFacilities().values()) {
      if (f.getCoord().getX() < minx) minx = f.getCoord().getX();
      if (f.getCoord().getY() < miny) miny = f.getCoord().getY();
      if (f.getCoord().getX() > maxx) maxx = f.getCoord().getX();
      if (f.getCoord().getY() > maxy) maxy = f.getCoord().getY();
    }
    minx -= 1.0D;
    miny -= 1.0D;
    maxx += 1.0D;
    maxy += 1.0D;
    QuadTree<Person> personQuadTree = new QuadTree<>(minx, miny, maxx, maxy);
    for (Person p : this.scenario.getPopulation().getPersons().values()) {
      Coord c =
          ((ActivityFacility)
                  this.scenario
                      .getActivityFacilities()
                      .getFacilities()
                      .get(
                          PopulationUtils.getFirstActivity(((Plan) p.getSelectedPlan()))
                              .getFacilityId()))
              .getCoord();
      personQuadTree.put(c.getX(), c.getY(), p);
    }
    log.info("PersonQuadTree has been created");
    this.personQuadTree = personQuadTree;
  }
 /**
  * Procedure that is run after intialization to find nodeclusters with one inlink or one outlink;
  * clusters these together with their upstream cluster (one inlink) or downstream cluster (one
  * outlink)
  */
 private TreeMap<Integer, NodeCluster> findLoopsAndLongLinks(
     TreeMap<Integer, NodeCluster> clusters) {
   logger.info("Finding loops and long links: START");
   boolean doneClustering = false;
   while (!doneClustering) {
     // TreeMap<Integer, NodeCluster> currentNCs = nodeClusterHistory
     // .pollLastEntry().getValue();
     // get a single new NodeCluster for this step
     NodeCluster newCluster = findSingleInLinkClusters(clusters);
     if (newCluster == null) break;
     newCluster.freezeCluster();
     clusters = updateClusterTree(clusters, newCluster);
     updateLinksAndNodes(newCluster);
     pointersToClusterLevels.put(clusterSteps, new ArrayList<>(clusters.values()));
     logger.info(
         String.format(
             "Step %05d of %05d: c1: %05d + c2: %05d = %05d, flow = %08.2f, deltaFlow = %08.2f",
             clusterSteps,
             this.leafNodeClusters.size(),
             newCluster.getChild1().getId(),
             newCluster.getChild2().getId(),
             newCluster.getId(),
             newCluster.getInternalFlow(),
             newCluster.getDeltaFlow()));
     clusterSteps++;
   }
   logger.info("Finding loops and long links: DONE");
   return clusters;
 }
示例#27
0
  public void insert() throws RowExistsException {
    if (milog.isInfoEnabled()) {
      milog.info("Telefono de: " + telefono.idGeneral);
    }
    try {
      Connection conn = ConnectionManager.getConection();
      Statement stmt = conn.createStatement();
      ResultSet rs = null;

      StringBuffer sqlString = new StringBuffer("INSERT INTO " + nombreTabla);
      sqlString.append(" VALUES (" + MysqlUtils.toMysqlString(telefono.getIdGeneral()) + ", ");
      sqlString.append(MysqlUtils.toMysqlString(telefono.getDescTelefono()) + ", ");
      sqlString.append(MysqlUtils.toMysqlString(telefono.getTelefono()) + ", ");
      sqlString.append(MysqlUtils.toMysqlString(telefono.getTelefono2()) + ")");

      if (milog.isInfoEnabled()) {
        milog.info("comando sql: " + sqlString);
      }
      stmt.execute(sqlString.toString());
    } catch (Exception ex) {
      if (milog.isInfoEnabled()) {
        milog.info("error: " + ex.toString());
      }
      throw new RowExistsException();
    }
  }
示例#28
0
  public boolean enqueueTaskReservations(TEnqueueTaskReservationsRequest request) {
    LOG.debug(Logging.functionCall(request));
    AUDIT_LOG.info(
        Logging.auditEventString(
            "node_monitor_enqueue_task_reservation", ipAddress, request.requestId));
    LOG.info(
        "Received enqueue task reservation request from "
            + ipAddress
            + " for request "
            + request.requestId);

    InetSocketAddress schedulerAddress =
        new InetSocketAddress(
            request.getSchedulerAddress().getHost(), request.getSchedulerAddress().getPort());
    requestSchedulers.put(request.getRequestId(), schedulerAddress);

    InetSocketAddress socket = appSockets.get(request.getAppId());
    if (socket == null) {
      LOG.error(
          "No socket stored for "
              + request.getAppId()
              + " (never registered?). "
              + "Can't launch task.");
      return false;
    }
    scheduler.submitTaskReservations(request, socket);
    return true;
  }
示例#29
0
  /**
   * Add a photo to a photoset.
   *
   * @param ssPhotoset the photoset to add the photo to.
   * @param photo the photo to add.
   * @throws Exception if there are any errors, or if either parameter is null.
   */
  public void addPhoto(SSPhotoset ssPhotoset, Photo photo) throws Exception {
    if (ssPhotoset == null) {
      throw new Exception("addPhoto: PARAMETER CANNOT BE NULL.");
    }
    if (photo == null) {
      throw new Exception("addPhoto: PHOTO CANNOT BE NULL.");
    }

    //	RequestContext rc = FlickrHelper.getInstance().getRequestContext();
    //	PhotosetsInterface pi = FlickrHelper.getInstance().getPhotosetsInterface();

    try {
      //	    pi.addPhoto(ssPhotoset.getId(), photo.getId());
      //	    PhotosetsApi.getInstance().addPhoto(ssPhotoset.getId(), photo.getId());
      Response response =
          JinxFactory.getInstance()
              .getPhotosetsApi()
              .addPhoto(ssPhotoset.getPhotosetId(), photo.getPhotoId());
      if (response.getCode() == 0) {
        logger.info("Photo " + photo.getTitle() + " added to set " + ssPhotoset.getTitle());
      } else if (response.getCode() == 3) {
        logger.info("Photo " + photo.getTitle() + " already in set, not added.");
      }
    } catch (JinxException fe) {
      logger.warn("Unexpected flickr error", fe);
    } catch (Exception e) {
      logger.error("Unexpected error.", e);
    }
  }
示例#30
0
  private Inversion_mercado_dineroTO getMercadoDinero(ClienteTO clienteTO, Session session)
      throws Exception {
    Inversion_mercado_dineroTO inversion_mercado_dineroTO = null;
    long numContrato = Long.valueOf(clienteTO.getNumContratoInvReportos());
    Double saldo = 0.0;
    if (numContrato > 0) {
      inversion_mercado_dineroTO = new Inversion_mercado_dineroTO();
      CuentaMercadoDineroCommand command = new CuentaMercadoDineroCommand();
      Resumen_Operaciones_Mercado_DineroTO responseCommand;

      try {
        responseCommand =
            command.ejecutaResumenOperacines(
                clienteTO, InversionesRequestTO.OPERACION_RESUMEN_OPERACIONES_VIGENTES, "ELITE");
        Collection<Detalle_OperacionTO> coleccion_operaciones =
            responseCommand.getColeccion_operaciones();
        if (coleccion_operaciones.size() > 0) {
          for (Detalle_OperacionTO operacion : coleccion_operaciones) {
            saldo += operacion.getMonto();
          }
        }
      } catch (InversionesGenericException e) {
        e.printStackTrace();
      }
      log.info("saldo antes: " + saldo);
      saldo = Double.valueOf(Formatter.getMontoTruncado(saldo.toString(), 2));
      log.info("saldo despues: " + saldo);
      inversion_mercado_dineroTO.setNumero_contrato(String.valueOf(numContrato));
      inversion_mercado_dineroTO.setSaldo_actual(String.valueOf(saldo));
    }
    return inversion_mercado_dineroTO;
  }