Beispiel #1
0
 /**
  * Implement to provide metadata to the metadata for use by the engine. This is the primary method
  * of creating metadata for dynamic VDBs.
  *
  * @param metadataFactory
  * @param conn may be null if the source is not required
  * @throws TranslatorException to indicate a recoverable error, otherwise a RuntimeException
  * @see #isSourceRequiredForMetadata()
  */
 public void getMetadata(MetadataFactory metadataFactory, C conn) throws TranslatorException {
   MetadataProcessor mp = getMetadataProcessor();
   if (mp != null) {
     PropertiesUtils.setBeanProperties(
         mp, metadataFactory.getModelProperties(), "importer"); // $NON-NLS-1$
     mp.process(metadataFactory, conn);
   }
 }
  public void initialize(Properties info) {
    PropertiesUtils.setBeanProperties(this, info, "org.teiid.sockets"); // $NON-NLS-1$
    this.pingTimer = new Timer("SocketPing", true); // $NON-NLS-1$
    this.pingTimer.schedule(
        new TimerTask() {

          @Override
          public void run() {
            Set<Map.Entry<HostInfo, Set<SessionToken>>> sessionEntries = null;
            synchronized (sessions) {
              sessionEntries =
                  new HashSet<Map.Entry<HostInfo, Set<SessionToken>>>(sessions.entrySet());
            }
            for (Map.Entry<HostInfo, Set<SessionToken>> entry : sessionEntries) {
              SocketServerInstance instance = null;
              HashSet<SessionToken> entries = null;
              synchronized (sessions) {
                entries = new HashSet<SessionToken>(entry.getValue());
              }
              try {
                instance = getServerInstance(entry.getKey());
                ILogon logon = instance.getService(ILogon.class);
                if ("07.01.01".compareTo(instance.getServerVersion()) > 0
                    || //$NON-NLS-1$
                    "7.1.1".compareTo(instance.getServerVersion()) > 0) { // $NON-NLS-1$
                  for (SessionToken session : entries) {
                    try {
                      logon.assertIdentity(session);
                      logon.ping();
                      log.log(Level.FINER, "issueing ping for session:", session); // $NON-NLS-1$
                    } catch (InvalidSessionException e) {
                    }
                  }
                } else {
                  ArrayList<String> sessionStrings = new ArrayList<String>(entry.getValue().size());
                  for (SessionToken session : entries) {
                    sessionStrings.add(session.getSessionID());
                  }
                  logon.ping(sessionStrings);
                  log.log(
                      Level.FINER, "issueing ping for sessions:", sessionStrings); // $NON-NLS-1$
                }
              } catch (Exception e) {
                log.log(Level.WARNING, "Error performing keep-alive ping", e); // $NON-NLS-1$
              } finally {
                if (instance != null) {
                  instance.shutdown();
                }
              }
            }
          }
        },
        ServerConnection.PING_INTERVAL,
        ServerConnection.PING_INTERVAL);
    this.channelFactory = new OioOjbectChannelFactory(info);
  }