Beispiel #1
0
  @Override
  public void execute() throws TranslatorException {

    LogManager.logTrace(
        LogConstants.CTX_CONNECTOR,
        "ObjectExecution command:",
        query.toString(),
        "using connection:",
        connection.getClass().getName()); // $NON-NLS-1$ //$NON-NLS-2$

    String nameInSource =
        getNameInSource(((NamedTable) query.getFrom().get(0)).getMetadataObject());

    List<Object> results = factory.search(query, nameInSource, connection, executionContext);

    if (results != null && results.size() > 0) {
      LogManager.logDetail(
          LogConstants.CTX_CONNECTOR,
          "ObjectExecution number of returned objects is :",
          results.size()); // $NON-NLS-1$

    } else {
      LogManager.logDetail(
          LogConstants.CTX_CONNECTOR,
          "ObjectExecution number of objects returned is : 0"); //$NON-NLS-1$

      results = Collections.emptyList();
    }

    this.resultsIt = results.iterator();
  }
 public void send(Message message, Serializable messageKey) {
   message.setMessageKey(messageKey);
   if (LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT, MessageLevel.DETAIL)) {
     LogManager.logDetail(LogConstants.CTX_TRANSPORT, "send message: " + message); // $NON-NLS-1$
   }
   objectSocket.write(message);
 }
 private void processMessagePacket(Message packet) {
   if (LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT, MessageLevel.DETAIL)) {
     LogManager.logDetail(
         LogConstants.CTX_TRANSPORT, "processing message:" + packet); // $NON-NLS-1$
   }
   if (this.workContext.getSecurityHelper() != null) {
     this.workContext.getSecurityHelper().clearSecurityContext();
   }
   final ServerWorkItem work = new ServerWorkItem(this, packet.getMessageKey(), packet, this.csr);
   this.workContext.runInContext(work);
 }
Beispiel #4
0
 TempTable getOrCreateTempTable(
     String tempTableID,
     Command command,
     BufferManager buffer,
     boolean delegate,
     boolean forUpdate,
     CommandContext context)
     throws TeiidProcessingException, BlockedException, TeiidComponentException {
   TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
   if (tempTable != null) {
     if (processors != null) {
       TableProcessor withProcessor = processors.get(tempTableID);
       if (withProcessor != null) {
         buildWithTable(tempTableID, withProcessor, tempTable);
       }
     }
     return tempTable;
   }
   // allow implicit temp group definition
   List<ElementSymbol> columns = null;
   if (command instanceof Insert) {
     Insert insert = (Insert) command;
     GroupSymbol group = insert.getGroup();
     if (group.isImplicitTempGroupSymbol()) {
       columns = insert.getVariables();
     }
   }
   if (columns == null) {
     if (processors != null) {
       TableProcessor withProcessor = processors.get(tempTableID);
       if (withProcessor != null) {
         LogManager.logDetail(
             LogConstants.CTX_DQP,
             "Creating temporary table for with clause",
             tempTableID); //$NON-NLS-1$
         Create create = new Create();
         create.setTable(new GroupSymbol(tempTableID));
         create.setElementSymbolsAsColumns(withProcessor.columns);
         tempTable = addTempTable(tempTableID, create, buffer, true, context);
         buildWithTable(tempTableID, withProcessor, tempTable);
         return tempTable;
       }
     }
     throw new QueryProcessingException(
         QueryPlugin.Event.TEIID30226,
         QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30226, tempTableID));
   }
   LogManager.logDetail(
       LogConstants.CTX_DQP, "Creating temporary table", tempTableID); // $NON-NLS-1$
   Create create = new Create();
   create.setTable(new GroupSymbol(tempTableID));
   create.setElementSymbolsAsColumns(columns);
   return addTempTable(tempTableID, create, buffer, true, context);
 }
Beispiel #5
0
 public void remove() {
   if (!removed) {
     if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
       LogManager.logDetail(
           LogConstants.CTX_BUFFER_MGR,
           "Removing TupleBuffer:",
           this.tupleSourceID); // $NON-NLS-1$
     }
     this.batchBuffer = null;
     purge();
     this.manager.remove();
     removed = true;
   }
 }
Beispiel #6
0
  public static List<Object> performSearch(
      Select command, Class<?> type, String cacheName, CacheContainerWrapper cache)
      throws TranslatorException {

    LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Using Lucene Searching."); // $NON-NLS-1$

    // Map<?, ?> cache,
    SearchManager searchManager = Search.getSearchManager((Cache<?, ?>) cache.getCache(cacheName));

    QueryBuilder queryBuilder = searchManager.buildQueryBuilderForClass(type).get();

    BooleanJunction<BooleanJunction> junction = queryBuilder.bool();
    boolean createdQueries = buildQueryFromWhereClause(command.getWhere(), junction, queryBuilder);

    Query query = null;
    if (createdQueries) {
      query = junction.createQuery();
    } else {
      query = queryBuilder.all().createQuery();
    }

    CacheQuery cacheQuery = searchManager.getQuery(query, type); // rootNodeType

    List<Object> results = cacheQuery.list();
    if (results == null || results.isEmpty()) {
      return Collections.emptyList();
    }

    return results;
  }
Beispiel #7
0
  public static boolean visit(
      Like obj, BooleanJunction<BooleanJunction> junction, QueryBuilder queryBuilder)
      throws TranslatorException {
    LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing LIKE criteria."); // $NON-NLS-1$

    Expression lhs = obj.getLeftExpression();
    Expression rhs = obj.getRightExpression();

    Column c = null;
    Expression literalExp = null;
    if (lhs instanceof ColumnReference) {
      c = ((ColumnReference) lhs).getMetadataObject();
      literalExp = rhs;
    } else {
      c = ((ColumnReference) rhs).getMetadataObject();
      literalExp = lhs;
    }

    String value = null;
    if (literalExp instanceof Literal) {

      value = (String) escapeReservedChars(((Literal) literalExp).getValue());
      createLikeQuery(
          c, value.replaceAll("%", ""), junction, queryBuilder); // "*" //$NON-NLS-1$ //$NON-NLS-2$
    } else {
      final String msg =
          ObjectPlugin.Util.getString(
              "LuceneSearch.Unsupported_expression", //$NON-NLS-1$
              new Object[] {literalExp.toString(), "LIKE"}); // $NON-NLS-1$
      throw new TranslatorException(msg);
    }

    return true;
  }
Beispiel #8
0
  public ConnectorWork registerRequest(AtomicRequestMessage message)
      throws TeiidComponentException {
    checkStatus();
    AtomicRequestID atomicRequestId = message.getAtomicRequestID();
    LogManager.logDetail(
        LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); // $NON-NLS-1$

    final ConnectorWorkItem item = new ConnectorWorkItem(message, this);
    ConnectorWork proxy =
        (ConnectorWork)
            Proxy.newProxyInstance(
                ConnectorWork.class.getClassLoader(),
                new Class[] {ConnectorWork.class},
                new InvocationHandler() {
                  @Override
                  public Object invoke(Object proxy, Method method, Object[] args)
                      throws Throwable {
                    ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
                    try {
                      Thread.currentThread()
                          .setContextClassLoader(getExecutionFactory().getClass().getClassLoader());
                      return method.invoke(item, args);
                    } catch (InvocationTargetException e) {
                      throw e.getTargetException();
                    } finally {
                      Thread.currentThread().setContextClassLoader(originalCL);
                    }
                  }
                });

    Assertion.isNull(
        requestStates.put(atomicRequestId, proxy), "State already existed"); // $NON-NLS-1$
    return proxy;
  }
Beispiel #9
0
  private BasicSourceCapabilities buildCapabilities(ExecutionFactory<Object, Object> translator)
      throws TranslatorException {
    if (translator.isSourceRequiredForCapabilities()) {
      Object connection = null;
      Object connectionFactory = null;
      try {
        connectionFactory = getConnectionFactory();

        if (connectionFactory != null) {
          connection = translator.getConnection(connectionFactory, null);
        }
        if (connection == null) {
          throw new TranslatorException(
              QueryPlugin.Event.TEIID31108,
              QueryPlugin.Util.getString(
                  "datasource_not_found", getConnectionName())); // $NON-NLS-1$);
        }
        LogManager.logDetail(
            LogConstants.CTX_CONNECTOR,
            "Initializing the capabilities for",
            translatorName); //$NON-NLS-1$
        synchronized (executionFactory) {
          executionFactory.initCapabilities(connection);
        }
      } finally {
        if (connection != null) {
          translator.closeConnection(connection, connectionFactory);
        }
      }
    }
    BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(translator, id);
    return resultCaps;
  }
 /** Set the standard request controls */
 private void setRequestControls(byte[] cookie) throws TranslatorException {
   List<Control> ctrl = new ArrayList<Control>();
   SortKey[] keys = searchDetails.getSortKeys();
   try {
     if (keys != null) {
       ctrl.add(new SortControl(keys, Control.NONCRITICAL));
     }
     if (this.executionFactory.usePagination()) {
       ctrl.add(
           new PagedResultsControl(
               this.executionContext.getBatchSize(), cookie, Control.CRITICAL));
     }
     if (!ctrl.isEmpty()) {
       this.ldapCtx.setRequestControls(ctrl.toArray(new Control[ctrl.size()]));
       LogManager.logTrace(
           LogConstants.CTX_CONNECTOR,
           "Sort/pagination controls were created successfully."); //$NON-NLS-1$
     }
   } catch (NamingException ne) {
     final String msg =
         LDAPPlugin.Util.getString("LDAPSyncQueryExecution.setControlsError")
             + //$NON-NLS-1$
             " : "
             + ne.getExplanation(); // $NON-NLS-1$
     throw new TranslatorException(ne, msg);
   } catch (IOException e) {
     throw new TranslatorException(e);
   }
 }
  // GHH 20080326 - set all batches as last batch after an exception
  // is thrown calling a method on the enumeration.  Per Javadoc for
  // javax.naming.NamingEnumeration, enumeration is invalid after an
  // exception is thrown - by setting last batch indicator we prevent
  // it from being used again.
  // GHH 20080326 - also added return of explanation for generic
  // NamingException
  public List<?> next() throws TranslatorException {
    try {
      if (unwrapIterator != null) {
        if (unwrapIterator.hasNext()) {
          return unwrapIterator.next();
        }
        unwrapIterator = null;
      }
      // The search has been executed, so process up to one batch of
      // results.
      List<?> result = null;
      while (result == null && searchEnumeration != null && searchEnumeration.hasMore()) {
        SearchResult searchResult = (SearchResult) searchEnumeration.next();
        try {
          result = getRow(searchResult);
        } catch (InvalidNameException e) {

        }
      }

      if (result == null && this.executionFactory.usePagination()) {
        byte[] cookie = null;
        Control[] controls = ldapCtx.getResponseControls();
        if (controls != null) {
          for (int i = 0; i < controls.length; i++) {
            if (controls[i] instanceof PagedResultsResponseControl) {
              PagedResultsResponseControl prrc = (PagedResultsResponseControl) controls[i];
              cookie = prrc.getCookie();
            }
          }
        }

        if (cookie == null) {
          return null;
        }

        setRequestControls(cookie);
        executeSearch();
        return next();
      }

      if (result != null) {
        resultCount++;
      }
      return result;
    } catch (SizeLimitExceededException e) {
      if (resultCount != searchDetails.getCountLimit()) {
        String msg = LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12008);
        TranslatorException te = new TranslatorException(e, msg);
        if (executionFactory.isExceptionOnSizeLimitExceeded()) {
          throw te;
        }
        this.executionContext.addWarning(te);
        LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, msg);
      }
      return null; // GHH 20080326 - if size limit exceeded don't try to read more results
    } catch (NamingException ne) {
      throw new TranslatorException(ne, LDAPPlugin.Util.gs("ldap_error")); // $NON-NLS-1$
    }
  }
Beispiel #12
0
 public void reset() {
   super.reset();
   if (evaluator != null) {
     evaluator.reset();
   }
   evaluatedParams = false;
   if (parentContext != null) {
     super.getContext().setVariableContext(parentContext);
   }
   createVariableContext();
   CommandContext cc = super.getContext();
   if (cc != null) {
     // create fresh local state
     setContext(cc.clone());
   }
   done = false;
   currentState = null;
   finalTupleSource = null;
   beginBatch = 1;
   batchRows = null;
   lastBatch = false;
   // reset program stack
   programs.clear();
   LogManager.logTrace(
       org.teiid.logging.LogConstants.CTX_DQP, "ProcedurePlan reset"); // $NON-NLS-1$
 }
 @Override
 public CountResponse executeCount(Query query, List<SQLParam> parameters) {
   ConnectionImpl connection = null;
   try {
     String sql = query.toString();
     LogManager.logDetail(LogConstants.CTX_ODATA, "Teiid-Query:", sql); // $NON-NLS-1$
     connection = getConnection();
     final PreparedStatementImpl stmt = connection.prepareStatement(sql);
     if (!parameters.isEmpty()) {
       for (int i = 0; i < parameters.size(); i++) {
         stmt.setObject(i + 1, parameters.get(i).value, parameters.get(i).sqlType);
       }
     }
     ResultSet rs = stmt.executeQuery();
     rs.next();
     int count = rs.getInt(1);
     rs.close();
     stmt.close();
     return Responses.count(count);
   } catch (Exception e) {
     throw new ServerErrorException(e.getMessage(), e);
   } finally {
     try {
       if (connection != null) {
         connection.close();
       }
     } catch (SQLException e) {
     }
   }
 }
 public void exceptionOccurred(Throwable t) {
   LogManager.log(
       t instanceof IOException ? MessageLevel.DETAIL : MessageLevel.ERROR,
       LogConstants.CTX_TRANSPORT,
       t,
       "Unhandled exception, closing client instance"); //$NON-NLS-1$
 }
 public UsernameTokenProfile(String user, String passwd, boolean encryptedPassword) {
   this.encryptedPassword = encryptedPassword;
   this.passwd = passwd;
   this.user = user;
   LogManager.logDetail(
       WSManagedConnectionFactory.UTIL.getString("using_username_profile")); // $NON-NLS-1$
 }
  /**
   * Return the XMIHeader for the specified File or null if the file does not represent a MetaMatrix
   * model file.
   *
   * @param resource The file of a metamatrix model file.
   * @return The XMIHeader for the model file
   */
  public static XMIHeader getXmiHeader(final File resource) {
    if (resource != null && resource.isFile() && resource.exists() && resource.canRead()) {
      // check cache
      if (CACHE != null) {
        XMIHeader header = CACHE.getCachedXmiHeader(resource);
        if (header != null) {
          return header;
        }
      }
      try {
        XMIHeader header = XMIHeaderReader.readHeader(resource);
        // add to cache
        if (CACHE != null) {
          CACHE.setXmiHeaderToCache(resource, header);
        }
        return header;
      } catch (TeiidException e) {
        LogManager.logWarning(RuntimeMetadataPlugin.PLUGIN_ID, e, e.getMessage());
      } catch (IllegalArgumentException iae) {
        // Swallowing this exception because we're doing all three checks that would produce it.
        // If this exception is caught, it's because the files really were closed/deleted in another
        // thread and this
        // thread didn't know about it.
        // Fixes Defect 22117
      }
    }

    return null;
  }
Beispiel #17
0
  public static boolean visit(
      In obj, BooleanJunction<BooleanJunction> junction, QueryBuilder queryBuilder)
      throws TranslatorException {
    LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing IN criteria."); // $NON-NLS-1$

    Expression lhs = obj.getLeftExpression();

    Column mdIDElement = ((ColumnReference) lhs).getMetadataObject();

    List<Expression> rhsList = obj.getRightExpressions();
    boolean createdQuery = false;
    for (Expression expr : rhsList) {

      if (expr instanceof Literal) {
        Literal literal = (Literal) expr;

        // add these as OR queries
        createEqualsQuery(
            mdIDElement,
            escapeReservedChars(literal.getValue()),
            false,
            false,
            junction,
            queryBuilder);
        createdQuery = true;
      } else {
        String msg =
            ObjectPlugin.Util.getString(
                "LuceneSearch.Unsupported_expression", //$NON-NLS-1$
                new Object[] {expr, "IN"}); // $NON-NLS-1$
        throw new TranslatorException(msg);
      }
    }
    return createdQuery;
  }
 @Override
 public void cancel() throws TranslatorException {
   LogManager.logDetail(
       LogConstants.CTX_CONNECTOR,
       SpreadsheetExecutionFactory.UTIL.getString("cancel_query")); // $NON-NLS-1$
   this.rowIterator = null;
 }
Beispiel #19
0
 @Override
 public void stop(StopContext context) {
   this.repositoryInjector.getValue().removeTranslatorMetadata(this.translator.getName());
   this.statusCheckerInjector.getValue().translatorRemoved(this.translator.getName());
   LogManager.logInfo(
       LogConstants.CTX_RUNTIME,
       IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50010, this.translator.getName()));
 }
  @Override
  public void execute() throws TranslatorException {
    this.visitor = new MongoDBSelectVisitor(this.executionFactory, this.metadata);
    this.visitor.visitNode(this.command);

    if (!this.visitor.exceptions.isEmpty()) {
      throw this.visitor.exceptions.get(0);
    }

    LogManager.logInfo(LogConstants.CTX_CONNECTOR, this.command);

    DBCollection collection =
        this.mongoDB.getCollection(this.visitor.mongoDoc.getTargetTable().getName());
    if (collection != null) {
      // TODO: check to see how to pass the hint
      ArrayList<DBObject> ops = new ArrayList<DBObject>();
      buildAggregate(ops, "$project", this.visitor.unwindProject); // $NON-NLS-1$

      if (this.visitor.project.isEmpty()) {
        throw new TranslatorException(
            MongoDBPlugin.Event.TEIID18025, MongoDBPlugin.Util.gs(MongoDBPlugin.Event.TEIID18025));
      }

      if (this.visitor.projectBeforeMatch) {
        buildAggregate(ops, "$project", this.visitor.project); // $NON-NLS-1$
      }

      if (!this.visitor.unwindTables.isEmpty()) {
        for (String ref : this.visitor.unwindTables) {
          buildAggregate(ops, "$unwind", "$" + ref); // $NON-NLS-1$ //$NON-NLS-2$
        }
      }
      buildAggregate(ops, "$match", this.visitor.match); // $NON-NLS-1$

      buildAggregate(ops, "$group", this.visitor.group); // $NON-NLS-1$
      buildAggregate(ops, "$match", this.visitor.having); // $NON-NLS-1$

      if (!this.visitor.projectBeforeMatch) {
        buildAggregate(ops, "$project", this.visitor.project); // $NON-NLS-1$
      }

      buildAggregate(ops, "$sort", this.visitor.sort); // $NON-NLS-1$
      buildAggregate(ops, "$skip", this.visitor.skip); // $NON-NLS-1$
      buildAggregate(ops, "$limit", this.visitor.limit); // $NON-NLS-1$

      try {
        AggregationOptions options =
            AggregationOptions.builder()
                .batchSize(this.executionContext.getBatchSize())
                .outputMode(AggregationOptions.OutputMode.CURSOR)
                .allowDiskUse(this.executionFactory.useDisk())
                .build();
        this.results = collection.aggregate(ops, options);
      } catch (MongoException e) {
        throw new TranslatorException(e);
      }
    }
  }
 /**
  * Return the XMIHeader for the specified inputstream of a model file.
  *
  * @param resourceStream The inputStream of a metamatrix model file.
  * @return The XMIHeader for the model file
  */
 public static XMIHeader getXmiHeader(final InputStream resourceStream) {
   if (resourceStream != null) {
     try {
       return XMIHeaderReader.readHeader(resourceStream);
     } catch (TeiidException e) {
       LogManager.logWarning(RuntimeMetadataPlugin.PLUGIN_ID, e, e.getMessage());
     }
   }
   return null;
 }
  /*
   * Deploy all jars in the supplied jarList
   * @param admin the Admin instance
   * @param jarList the colon-separated list of jar path locations
   */
  private void deployJars(Admin admin, String jarList) {
    // Path Entries are colon separated
    String[] jarPathStrs = jarList.split("[:]"); // $NON-NLS-1$

    // Attempt to deploy each jar
    for (String jarPathStr : jarPathStrs) {
      File theFile = new File(jarPathStr);
      if (theFile.exists()) {
        if (theFile.canRead()) {
          String fileName = theFile.getName();
          InputStream iStream = null;
          try {
            iStream = new FileInputStream(theFile);
          } catch (FileNotFoundException ex) {
            LogManager.logError(
                getClass().getSimpleName(),
                ex,
                NLS.bind(Messages.JarDeploymentJarNotFound, theFile.getPath()));
            continue;
          }
          try {
            admin.deployVDB(fileName, iStream);
          } catch (Exception ex) {
            // Jar deployment failed
            LogManager.logError(
                getClass().getSimpleName(),
                ex,
                NLS.bind(Messages.JarDeploymentFailed, theFile.getPath()));
          }
        } else {
          // Could not read the file
          LogManager.logError(
              getClass().getSimpleName(),
              NLS.bind(Messages.JarDeploymentJarNotReadable, theFile.getPath()));
        }
      } else {
        // The file was not found
        LogManager.logError(
            getClass().getSimpleName(),
            NLS.bind(Messages.JarDeploymentJarNotFound, theFile.getPath()));
      }
    }
  }
Beispiel #23
0
 public <T> Dispatch<T> createDispatch(Class<T> type, Mode mode) throws IOException {
   if (this.wsdlService == null) {
     Bus bus = BusFactory.getThreadDefaultBus();
     BusFactory.setThreadDefaultBus(this.mcf.getBus());
     try {
       this.wsdlService = Service.create(this.mcf.getWsdlUrl(), this.mcf.getServiceQName());
     } finally {
       BusFactory.setThreadDefaultBus(bus);
     }
     if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
       LogManager.logDetail(
           LogConstants.CTX_WS, "Created the WSDL service for", this.mcf.getWsdl()); // $NON-NLS-1$
     }
   }
   Dispatch<T> dispatch = this.wsdlService.createDispatch(this.mcf.getPortQName(), type, mode);
   configureWSSecurity(dispatch);
   setDispatchProperties(dispatch, "SOAP12"); // $NON-NLS-1$
   return dispatch;
 }
Beispiel #24
0
  /**
   * @param port
   * @param inputBufferSize
   * @param outputBufferSize
   * @param engine null if SSL is disabled
   * @param bindaddress
   * @param server
   */
  public SocketListener(
      InetSocketAddress address,
      int inputBufferSize,
      int outputBufferSize,
      int maxWorkers,
      SSLConfiguration config,
      ClientServiceRegistryImpl csr,
      StorageManager storageManager) {
    if (config != null) {
      this.isClientEncryptionEnabled = config.isClientEncryptionEnabled();
    }
    this.csr = csr;

    this.nettyPool = Executors.newCachedThreadPool(new NamedThreadFactory("NIO")); // $NON-NLS-1$
    if (LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT, MessageLevel.DETAIL)) {
      LogManager.logDetail(
          LogConstants.CTX_TRANSPORT,
          "server = "
              + address.getAddress()
              + "binding to port:"
              + address.getPort()); // $NON-NLS-1$ //$NON-NLS-2$
    }

    if (maxWorkers == 0) {
      maxWorkers = Runtime.getRuntime().availableProcessors();
    }

    ChannelFactory factory =
        new NioServerSocketChannelFactory(this.nettyPool, this.nettyPool, maxWorkers);

    ServerBootstrap bootstrap = new ServerBootstrap(factory);
    this.channelHandler = createChannelPipelineFactory(config, storageManager);
    bootstrap.setPipelineFactory(channelHandler);
    if (inputBufferSize != 0) {
      bootstrap.setOption("receiveBufferSize", new Integer(inputBufferSize)); // $NON-NLS-1$
    }
    if (outputBufferSize != 0) {
      bootstrap.setOption("sendBufferSize", new Integer(outputBufferSize)); // $NON-NLS-1$
    }
    bootstrap.setOption("keepAlive", Boolean.TRUE); // $NON-NLS-1$

    this.serverChanel = bootstrap.bind(address);
  }
Beispiel #25
0
 public ResultsFuture<?> ping() throws InvalidSessionException, TeiidComponentException {
   // ping is double used to alert the aliveness of the client, as well as check the server
   // instance is
   // alive by socket server instance, so that they can be cached.
   String id = DQPWorkContext.getWorkContext().getSessionId();
   if (id != null) {
     this.service.pingServer(id);
   }
   LogManager.logTrace(LogConstants.CTX_SECURITY, "Ping", id); // $NON-NLS-1$
   return ResultsFuture.NULL_FUTURE;
 }
  public void stop() {
    LogManager.logDetail(
        LogConstants.CTX_DQP, "Stopping BufferManager using", bufferDir); // $NON-NLS-1$
    bufferMgr.shutdown();

    // Delete the buffer directory
    if (bufferDir != null) {
      cleanDirectory(bufferDir);
      bufferDir.delete();
    }
  }
Beispiel #27
0
 /**
  * Close processing and clean everything up. Should only be called by the same thread that called
  * process.
  */
 public void closeProcessing() {
   if (processorClosed) {
     return;
   }
   if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
     LogManager.logDetail(
         LogConstants.CTX_DQP, "QueryProcessor: closing processor"); // $NON-NLS-1$
   }
   this.context.getTupleSourceCache().close();
   this.bufferMgr.releaseBuffers(reserved);
   reserved = 0;
   processorClosed = true;
   if (initialized) {
     try {
       processPlan.close();
     } catch (TeiidComponentException e1) {
       LogManager.logDetail(LogConstants.CTX_DQP, e1, "Error closing processor"); // $NON-NLS-1$
     }
   }
 }
 private void buildAggregate(List<DBObject> query, String type, Object object) {
   if (object != null) {
     LogManager.logDetail(
         LogConstants.CTX_CONNECTOR,
         "{\""
             + type
             + "\": {"
             + object.toString()
             + "}}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     query.add(new BasicDBObject(type, object));
   }
 }
Beispiel #29
0
  @Override
  public void processError(ODataServerError error, ErrorResponse response) {
    int logLevel = error.getStatusCode() >= 500 ? MessageLevel.ERROR : MessageLevel.WARNING;
    Throwable ex = getRoot(error.getException());
    // many exceptions in TeiidServiceHandler default as INTERNAL_SERVER_ERROR
    // so we make a better check for codes here
    if (ex instanceof TeiidNotImplementedException) {
      error.setException((TeiidNotImplementedException) ex);
      error.setCode(((TeiidNotImplementedException) ex).getCode());
      error.setStatusCode(501);
      logLevel = MessageLevel.DETAIL;
    } else if (ex instanceof TeiidProcessingException) {
      error.setException((TeiidProcessingException) ex);
      error.setCode(((TeiidProcessingException) ex).getCode());
      error.setStatusCode(400);
      logLevel = MessageLevel.WARNING;
    } else if (ex instanceof TeiidException) {
      error.setException((TeiidException) ex);
      error.setCode(((TeiidException) ex).getCode());
      error.setStatusCode(500);
      logLevel = MessageLevel.ERROR;
    } else if (ex instanceof TeiidRuntimeException) {
      error.setException((TeiidRuntimeException) ex);
      error.setCode(((TeiidRuntimeException) ex).getCode());
      error.setStatusCode(500);
      logLevel = MessageLevel.ERROR;
    }

    if (ex != error.getException() && ex.getMessage() != null) {
      if (LogManager.isMessageToBeRecorded(LogConstants.CTX_ODATA, MessageLevel.DETAIL)
          || logLevel <= MessageLevel.ERROR) {
        LogManager.log(
            logLevel,
            LogConstants.CTX_ODATA,
            error.getException(),
            ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16050, error.getMessage(), ex.getMessage()));
      } else {
        LogManager.log(
            logLevel,
            LogConstants.CTX_DQP,
            ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16051, error.getMessage(), ex.getMessage()));
      }
    } else {
      if (LogManager.isMessageToBeRecorded(LogConstants.CTX_ODATA, MessageLevel.DETAIL)
          || logLevel <= MessageLevel.ERROR) {
        LogManager.log(
            logLevel,
            LogConstants.CTX_ODATA,
            error.getException(),
            ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16052, error.getMessage()));
      } else {
        LogManager.log(
            logLevel,
            LogConstants.CTX_DQP,
            ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16053, error.getMessage()));
      }
    }
    response.writeError(error);
  }
  public void resolveBlock(
      CreateProcedureCommand command,
      Block block,
      GroupContext originalExternalGroups,
      TempMetadataAdapter original)
      throws QueryResolverException, QueryMetadataException, TeiidComponentException {
    LogManager.logTrace(
        org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER,
        new Object[] {"Resolving block", block}); // $NON-NLS-1$

    // create a new variable and metadata context for this block so that discovered metadata is not
    // visible else where
    TempMetadataStore store = original.getMetadataStore().clone();
    TempMetadataAdapter metadata = new TempMetadataAdapter(original.getMetadata(), store);
    GroupContext externalGroups = new GroupContext(originalExternalGroups, null);

    // create a new variables group for this block
    GroupSymbol variables =
        ProcedureContainerResolver.addScalarGroup(
            ProcedureReservedWords.VARIABLES, store, externalGroups, new LinkedList<Expression>());

    for (Statement statement : block.getStatements()) {
      resolveStatement(command, statement, externalGroups, variables, metadata);
    }

    if (block.getExceptionGroup() != null) {
      // create a new variable and metadata context for this block so that discovered metadata is
      // not visible else where
      store = original.getMetadataStore().clone();
      metadata = new TempMetadataAdapter(original.getMetadata(), store);
      externalGroups = new GroupContext(originalExternalGroups, null);

      // create a new variables group for this block
      variables =
          ProcedureContainerResolver.addScalarGroup(
              ProcedureReservedWords.VARIABLES,
              store,
              externalGroups,
              new LinkedList<Expression>());
      isValidGroup(metadata, block.getExceptionGroup());

      if (block.getExceptionStatements() != null) {
        ProcedureContainerResolver.addScalarGroup(
            block.getExceptionGroup(), store, externalGroups, exceptionGroup, false);
        for (Statement statement : block.getExceptionStatements()) {
          resolveStatement(command, statement, externalGroups, variables, metadata);
        }
      }
    }
  }