Package org.apache.derby.iapi.services.context

Examples of org.apache.derby.iapi.services.context.ContextManager


     * We assume the System boot process has created a context
     * manager already, but not that contexts we need are there.
     */
    ContextService csf = ContextService.getFactory();

    ContextManager cm = csf.getCurrentContextManager();
    if (SanityManager.DEBUG)
      SanityManager.ASSERT((cm != null), "Failed to get current ContextManager");

    // RESOLVE other non-StandardException errors.
    bootingTC = null;
    try
    {
      // Get a transaction controller. This has the side effect of
      // creating a transaction context if there isn't one already.
      bootingTC = af.getTransaction(cm);

      /*
        We need an execution context so that we can generate rows
        REMIND: maybe only for create case?
       */
      exFactory.newExecutionContext(cm);

      DataDescriptorGenerator ddg = getDataDescriptorGenerator();

      //We should set the user schema collation type here now because
      //later on, we are going to create user schema APP. By the time any
      //user schema gets created, we should have the correct collation
      //type set for such schemas to use. For this reason, don't remove
      //the following if else statement and don't move it later in this
      //method.
      String userDefinedCollation;   
      if (create) {
        //Get the collation attribute from the JDBC url. It can only
        //have one of 2 possible values - UCS_BASIC or TERRITORY_BASED
        //This attribute can only be specified at database create time.
        //The attribute value has already been verified in DVF.boot and
        //hence we can be assured that the attribute value if provided
        //is either UCS_BASIC or TERRITORY_BASED. If none provided,
        //then we will take it to be the default which is UCS_BASIC.
        userDefinedCollation = startParams.getProperty(
            Attribute.COLLATION, Property.UCS_BASIC_COLLATION);   
        bootingTC.setProperty(Property.COLLATION,userDefinedCollation,true);
      } else {
        userDefinedCollation = startParams.getProperty(
            Property.COLLATION, Property.UCS_BASIC_COLLATION);
      }

      //Initialize the collation type of user schemas after looking at
      //collation property/attribute.
      if (userDefinedCollation.equalsIgnoreCase(Property.UCS_BASIC_COLLATION))
        collationTypeOfUserSchemas = StringDataValue.COLLATION_TYPE_UCS_BASIC;
      else
        collationTypeOfUserSchemas = StringDataValue.COLLATION_TYPE_TERRITORY_BASED;

      //Now is also a good time to create schema descriptor for global
      //temporary tables. Since this is a user schema, it should use the
      //collation type associated with user schemas. Since we just
      //finished setting up the collation type of user schema, it is
      //safe to create user SchemaDescriptor(s) now.
      declaredGlobalTemporaryTablesSchemaDesc =
              newDeclaredGlobalTemporaryTablesSchemaDesc(
                      SchemaDescriptor.STD_DECLARED_GLOBAL_TEMPORARY_TABLES_SCHEMA_NAME);
     
      if (create) {
        String userName = IdUtil.getUserNameFromURLProps(startParams);
        authorizationDatabaseOwner = IdUtil.getUserAuthorizationId(userName);
     
        // create any required tables.
        createDictionaryTables(startParams, bootingTC, ddg);
        //create procedures for network server metadata
        create_SYSIBM_procedures(bootingTC);
        //create metadata sps statement required for network server
        createSystemSps(bootingTC);
                // create the SYSCS_UTIL system procedures)
                create_SYSCS_procedures(bootingTC);
        // log the current dictionary version
        dictionaryVersion = softwareVersion;

        /* Set properties for current and create time
         * DataDictionary versions.
         */
        bootingTC.setProperty(
                    DataDictionary.CORE_DATA_DICTIONARY_VERSION,
                    dictionaryVersion, true);

        bootingTC.setProperty(
                    DataDictionary.CREATE_DATA_DICTIONARY_VERSION,
                    dictionaryVersion, true);

        // If SqlAuthorization is set as system property during database
        // creation, set it as database property also, so it gets persisted.
        if (PropertyUtil.getSystemBoolean(Property.SQL_AUTHORIZATION_PROPERTY))
        {
          bootingTC.setProperty(Property.SQL_AUTHORIZATION_PROPERTY,"true",true);
          usesSqlAuthorization=true;
        }
      } else {
        // Get the ids for non-core tables
        loadDictionaryTables(bootingTC, ddg, startParams);
        SchemaDescriptor sd = locateSchemaRow(SchemaDescriptor.IBM_SYSTEM_SCHEMA_NAME,
                 bootingTC);
        authorizationDatabaseOwner = sd.getAuthorizationId();
        String sqlAuth = PropertyUtil.getDatabaseProperty(bootingTC,
                    Property.SQL_AUTHORIZATION_PROPERTY);

        // Feature compatibility check.
        if (Boolean.valueOf
            (startParams.getProperty(
              Attribute.SOFT_UPGRADE_NO_FEATURE_CHECK))
            .booleanValue()) {
          // Do not perform check if this boot is the first
          // phase (soft upgrade boot) of a hard upgrade,
          // which happens in two phases beginning with
          // DERBY-2264. In this case, we need to always be
          // able to boot to authenticate, notwithstanding
          // any feature properties set
          // (e.g. derby.database.sqlAuthorization) which
          // may not yet be supported until that hard
          // upgrade has happened, normally causing an error
          // below.
          //
          // Feature sqlAuthorization is a special case:
          // Since database ownership checking only happens
          // when sqlAuthorization is true, we can't afford
          // to *not* use it for upgrades from 10.2 or
          // later, lest we lose the database owner check.
          // For upgrades from 10.1 and earlier there is no
          // database owner check at a hard upgrade.
          if (dictionaryVersion.majorVersionNumber >=
            DataDictionary.DD_VERSION_DERBY_10_2) {
            usesSqlAuthorization = Boolean.valueOf(sqlAuth).
              booleanValue();
          }
        } else {
          if (Boolean.valueOf(sqlAuth).booleanValue()) {
            // SQL authorization requires 10.2 or higher database
            checkVersion(DataDictionary.DD_VERSION_DERBY_10_2,
                   "sqlAuthorization");
            usesSqlAuthorization=true;
          }
        }
      }
         
      if (SanityManager.DEBUG)
        SanityManager.ASSERT((authorizationDatabaseOwner != null), "Failed to get Database Owner authorization");

      /* Commit & destroy the create database */
      bootingTC.commit();
      cm.getContext(ExecutionContext.CONTEXT_ID).popMe(); // done with ctx
    } finally {

      if (bootingTC != null) {
        bootingTC.destroy()// gets rid of the transaction context
        bootingTC = null;
View Full Code Here


    // client may have unsubscribed while it had items queued
    if (client == null)
      return;

    ContextManager cm = contextMgr;

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(cm != null, "Context manager is null");
      SanityManager.ASSERT(client != null, "client is null");
    }

    try
    {
      int status = client.performWork(cm);

      if (clientRecord.subscriber)
        return;

      if (status == Serviceable.REQUEUE)
      {
        List queue = client.serviceASAP() ? highPQ : normPQ;
        synchronized (this) {
          queue.add(clientRecord);

          if (SanityManager.DEBUG) {

            if (SanityManager.DEBUG_ON("memoryLeakTrace")) {

              if (queue.size() > (OPTIMAL_QUEUE_SIZE * 2))
                System.out.println("memoryLeakTrace:BasicDaemon " + queue.size());
            }
          }
        }
      }

      return;
    }
    catch (Throwable e)
    {
      if (SanityManager.DEBUG)
        SanityManager.showTrace(e);

            //Assume database is not active. DERBY-4856 thread dump
            cm.cleanupOnError(e, false);
    }
  }
View Full Code Here

     * @param global_id The global transaction we are searching for.
     **/
  public ContextManager findTransactionContextByGlobalId(
    GlobalXactId global_id)
  {
        ContextManager cm              = null;

        // Need to hold sync while linear searching the hash table.
        synchronized (trans)
        {
            for (Enumeration e = trans.elements(); e.hasMoreElements();)
View Full Code Here

   *
   * @exception StandardException thrown if something goes wrong
   */
  private void resetSavepoints() throws StandardException
  {
    final ContextManager cm = getContextManager();
    final List stmts = cm.getContextStack(org.apache.derby.
                        iapi.reference.
                        ContextId.LANG_STATEMENT);
    final int end = stmts.size();
    for (int i = 0; i < end; ++i) {
      ((StatementContext)stmts.get(i)).resetSavePoint();
View Full Code Here

            // error we get at this point is going to shut down the db.

            while (true)
            {
                // allocate new context and associate new xact with it.
                ContextManager cm      = contextFactory.newContextManager();
                contextFactory.setCurrentContextManager(cm);

        try {
                RawTransaction rawtran =
                    startTransaction(
View Full Code Here

                    C_NodeTypes.TABLE_NAME,
                    null,
                    null,
                    getContextManager());

    ContextManager cm = getContextManager();

    int size = visibleSize();
    for (int index = 0; index < size; index++)
    {
      boolean     nullableResult;
View Full Code Here

    TableName  tableName,
    String    columnName
  )
    throws StandardException
  {
    ContextManager  cm = getContextManager();
    NodeFactory    nodeFactory = getNodeFactory();

    ResultColumn  rc = (ResultColumn) nodeFactory.getNode
      (
        C_NodeTypes.RESULT_COLUMN,
View Full Code Here

    TableDescriptor        triggerTable,
    TransactionController       tc
  )
    throws StandardException
  {
    ContextManager cm = lcc.getContextManager();
    DependencyManager dm;
    ProviderInfo[] providerInfo;

    LanguageConnectionFactory  lcf = lcc.getLanguageConnectionFactory();
View Full Code Here

    */
    if (recompIfInvalid &&
      (!valid ||
       (preparedStatement == null)))
    {
      ContextManager cm = ContextService.getFactory().getCurrentContextManager();

      /*
      ** Find the language connection context.  Get
      ** it each time in case a connection is dropped.
      */
      LanguageConnectionContext lcc = (LanguageConnectionContext)
          cm.getContext(LanguageConnectionContext.CONTEXT_ID);
     


      if (!((org.apache.derby.impl.sql.catalog.DataDictionaryImpl) (lcc.getDataDictionary())).readOnlyUpgrade) {

View Full Code Here

    //REMIND: someone is leaving an incorrect manager on when they
    // are exiting the system in the nested case.
    if (SanityManager.DEBUG)
    {
      if (tr.getCsf() != null) {
        ContextManager cm1 = tr.getCsf().getCurrentContextManager();
        ContextManager cm2 = tr.getContextManager();
        // If the system has been shut down, cm1 can be null.
        // Otherwise, cm1 and cm2 should be identical.
        Util.ASSERT(this, (cm1 == cm2 || cm1 == null),
          "Current Context Manager not the one was expected: " +
           cm1 + " " + cm2);
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.services.context.ContextManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.