Search in sources :

Example 61 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class Timeout method buildLockTableString.

/**
 * buildLockTableString creates a LockTable info String
 */
private String buildLockTableString() throws StandardException {
    sb = new StringBuffer(8192);
    outputRow = new char[LENGTHOFTABLE];
    // counter
    int i;
    // need language here to print out tablenames
    LanguageConnectionContext lcc = (LanguageConnectionContext) Deadlock.getContext(LanguageConnectionContext.CONTEXT_ID);
    if (lcc != null)
        tc = lcc.getTransactionExecute();
    try {
        tabInfo = new TableNameInfo(lcc, true);
    } catch (Exception se) {
    // just don't do anything
    }
    sb.append(newline);
    sb.append(new Date(currentTime));
    sb.append(newline);
    for (i = 0; i < column.length; i++) {
        sb.append(column[i]);
        sb.append(SEPARATOR);
    }
    sb.append(newline);
    for (i = 0; i < LENGTHOFTABLE; i++) sb.append(LINE);
    sb.append(newline);
    // get the timeout lock info
    if (currentLock != null) {
        dumpLock();
        if (timeoutInfoHash()) {
            sb.append("*** The following row is the victim ***");
            sb.append(newline);
            sb.append(outputRow);
            sb.append(newline);
            sb.append("*** The above row is the victim ***");
            sb.append(newline);
        } else {
            sb.append("*** A victim was chosen, but it cannot be printed because the lockable object, " + currentLock + ", does not want to participate ***");
            sb.append(newline);
        }
    }
    // get lock info from the rest of the table
    if (lockTable != null) {
        while (lockTable.hasMoreElements()) {
            currentLock = (Latch) lockTable.nextElement();
            dumpLock();
            if (timeoutInfoHash()) {
                sb.append(outputRow);
                sb.append(newline);
            } else {
                sb.append("*** A latch/lock, " + currentLock + ", exist in the lockTable that cannot be printed ***");
                sb.append(newline);
            }
        }
        for (i = 0; i < LENGTHOFTABLE; i++) sb.append(LINE);
        sb.append(newline);
    }
    return sb.toString();
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) StandardException(org.apache.derby.shared.common.error.StandardException) Date(java.util.Date)

Example 62 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class BaseMonitor method bootProviderServices.

/**
 *		Boot all persistent services that can be located by a single service provider
 *
 *		<BR>
 *		This method enumerates through all the service providers that
 *		are active and calls bootPersistentServices(PersistentService)
 *		to boot all the services that that provider knows about.
 */
protected void bootProviderServices(PersistentService provider) {
    if (SanityManager.DEBUG && reportOn) {
        report("Booting persistent services for provider: " + provider.getType());
    }
    for (Enumeration e = provider.getBootTimeServices(); (e != null) && e.hasMoreElements(); ) {
        String serviceName = (String) e.nextElement();
        Properties serviceProperties;
        try {
            serviceProperties = provider.getServiceProperties(serviceName, null);
        } catch (StandardException mse) {
            report("Failed to load service properties, name: " + serviceName + ", type = " + provider.getType());
            reportException(mse);
            continue;
        }
        // see if this service does not want to be auto-booted.
        if (Boolean.valueOf(serviceProperties.getProperty(Property.NO_AUTO_BOOT)).booleanValue())
            continue;
        try {
            startProviderService(provider, serviceName, serviceProperties);
        } catch (StandardException mse) {
            report("Service failed to boot, name: " + serviceName + ", type = " + provider.getType());
            reportException(mse);
            continue;
        }
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) Enumeration(java.util.Enumeration) Properties(java.util.Properties)

Example 63 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class BaseMonitor method findProviderAndStartService.

/**
 *		Find a provider and start  a service.
 */
private boolean findProviderAndStartService(String name, Properties properties, boolean bootTime) throws StandardException {
    PersistentService actualProvider = null;
    Properties serviceProperties = null;
    String serviceName = null;
    // see if the name already includes a service type
    int colon = name.indexOf(':');
    if (colon != -1) {
        actualProvider = findProviderFromName(name, colon);
        // throw an exception
        if (actualProvider != null) {
            serviceName = actualProvider.getCanonicalServiceName(name);
            if (serviceName == null)
                // we understand the type, but the service does not exist
                return true;
            serviceProperties = actualProvider.getServiceProperties(serviceName, properties);
            if (serviceProperties == null)
                // we understand the type, but the service does not exist
                return true;
            // see if this service does not want to be auto-booted.
            if (bootTime && Boolean.valueOf(serviceProperties.getProperty(Property.NO_AUTO_BOOT)).booleanValue())
                return true;
            startProviderService(actualProvider, serviceName, serviceProperties);
            // we understand the type
            return true;
        }
    }
    StandardException savedMse = null;
    for (Enumeration e = new ProviderEnumeration(properties); e.hasMoreElements(); ) {
        PersistentService provider = (PersistentService) e.nextElement();
        String sn = provider.getCanonicalServiceName(name);
        if (sn == null)
            continue;
        Properties p = null;
        try {
            p = provider.getServiceProperties(sn, properties);
            // service does not exist.
            if (p == null)
                continue;
        } catch (StandardException mse) {
            savedMse = mse;
        }
        // yes we can attempt to boot this service
        if (actualProvider == null) {
            actualProvider = provider;
            serviceName = sn;
            serviceProperties = p;
            continue;
        }
        // we have an ambigious service name
        throw StandardException.newException(SQLState.AMBIGIOUS_PROTOCOL, name);
    }
    // the monitor claims to always understand these.
    if (actualProvider == null)
        return colon == -1;
    if (savedMse != null)
        throw savedMse;
    // see if this service does not want to be auto-booted.
    if (bootTime && Boolean.valueOf(serviceProperties.getProperty(Property.NO_AUTO_BOOT)).booleanValue())
        return true;
    startProviderService(actualProvider, serviceName, serviceProperties);
    return true;
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) Enumeration(java.util.Enumeration) PersistentService(org.apache.derby.iapi.services.monitor.PersistentService) Properties(java.util.Properties)

Example 64 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class AuthenticationServiceBase method getProperty.

/**
 * Returns a property if it was set at the database or
 * system level. Treated as SERVICE property by default.
 *
 * @return a property string value.
 */
public String getProperty(String key) {
    String propertyValue = null;
    TransactionController tc = null;
    try {
        tc = getTransaction();
        propertyValue = PropertyUtil.getServiceProperty(tc, key, (String) null);
        if (tc != null) {
            tc.commit();
            tc = null;
        }
    } catch (StandardException se) {
    // Do nothing and just return
    }
    return propertyValue;
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Example 65 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class AuthenticationServiceBase method getDatabaseProperty.

public String getDatabaseProperty(String key) {
    String propertyValue = null;
    TransactionController tc = null;
    try {
        if (store != null)
            tc = store.getTransaction(getContextService().getCurrentContextManager());
        propertyValue = PropertyUtil.getDatabaseProperty(tc, key);
        if (tc != null) {
            tc.commit();
            tc = null;
        }
    } catch (StandardException se) {
    // Do nothing and just return
    }
    return propertyValue;
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Aggregations

StandardException (org.apache.derby.shared.common.error.StandardException)276 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)43 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)37 IOException (java.io.IOException)32 Properties (java.util.Properties)29 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)27 TransactionController (org.apache.derby.iapi.store.access.TransactionController)26 ContextManager (org.apache.derby.iapi.services.context.ContextManager)22 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)20 SQLException (java.sql.SQLException)17 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)17 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)16 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)12 RowLocation (org.apache.derby.iapi.types.RowLocation)11 SQLLongint (org.apache.derby.iapi.types.SQLLongint)11 StorageFile (org.apache.derby.io.StorageFile)10 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)9 ScanController (org.apache.derby.iapi.store.access.ScanController)9 File (java.io.File)8 LogInstant (org.apache.derby.iapi.store.raw.log.LogInstant)8