Пример #1
0
 void runServer() throws Exception {
   System.setProperty("jgroups.bind_addr", host);
   if (port > 0) {
     Protocol transport = ch.getProtocolStack().getTransport();
     if (transport instanceof TP) {
       ((TP) transport).setBindPort(port);
     }
   }
   ch.connect(null); // this makes it a unicast channel
   System.out.println(
       "server started at " + new java.util.Date() + ", listening on " + ch.getAddress());
   while (ch.isOpen()) {
     Util.sleep(10000);
   }
 }
Пример #2
0
 protected void close() {
   if (iChannel != null && iChannel.isConnected()) iChannel.disconnect();
   if (iChannel != null && iChannel.isOpen()) iChannel.close();
   OnlineSectioningLogger.stopLogger();
   HibernateUtil.closeHibernate();
 }
Пример #3
0
  protected void startServer() {
    final Session session =
        Session.getSessionUsingInitiativeYearTerm(
            ApplicationProperties.getProperty("initiative", "woebegon"),
            ApplicationProperties.getProperty("year", "2010"),
            ApplicationProperties.getProperty("term", "Fal"));

    boolean remote = "true".equalsIgnoreCase(ApplicationProperties.getProperty("remote", "true"));

    if (session == null) {
      sLog.error(
          "Academic session not found, use properties initiative, year, and term to set academic session.");
      System.exit(0);
    } else {
      sLog.info("Session: " + session);
    }

    iSessionId = session.getUniqueId();

    OnlineSectioningLogger.getInstance().setEnabled(false);

    if (remote) {
      try {
        iChannel =
            new JChannel(
                JGroupsUtils.getConfigurator(
                    ApplicationProperty.SolverClusterConfiguration.value()));
        iChannel.setUpHandler(new MuxUpHandler());

        iSolverServer = new DummySolverServer(iChannel);

        iChannel.connect("UniTime:rpc");
        iChannel.getState(null, 0);

        if (getServer() == null) throw new Exception(session.getLabel() + " is not available");
      } catch (Exception e) {
        sLog.error("Failed to access the solver server: " + e.getMessage(), e);
        if (iChannel != null && iChannel.isConnected()) iChannel.disconnect();
        if (iChannel != null && iChannel.isOpen()) iChannel.close();
        System.exit(0);
      }
    } else {
      iServer =
          new InMemoryServer(
              new OnlineSectioningServerContext() {
                @Override
                public boolean isWaitTillStarted() {
                  return true;
                }

                @Override
                public EmbeddedCacheManager getCacheManager() {
                  return null;
                }

                @Override
                public Long getAcademicSessionId() {
                  return session.getUniqueId();
                }

                @Override
                public LockService getLockService() {
                  return null;
                }
              });
    }
  }