Skip to content

Commit

Permalink
Merge branch '8.4.x' of https://github.com/teiid/teiid
Browse files Browse the repository at this point in the history
Conflicts:
	jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
	jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
	runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
	runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
	runtime/src/main/resources/org/teiid/runtime/i18n.properties
  • Loading branch information
shawkins committed Aug 1, 2013
2 parents 1568336 + 70ab09c commit 3a02d6b
Show file tree
Hide file tree
Showing 22 changed files with 302 additions and 256 deletions.
18 changes: 15 additions & 3 deletions client/src/main/java/org/teiid/client/util/ResultsFuture.java
Expand Up @@ -27,7 +27,10 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.teiid.jdbc.JDBCPlugin;


/**
Expand All @@ -36,11 +39,12 @@
*/
public class ResultsFuture<T> implements Future<T> {

public static ResultsFuture<Void> NULL_FUTURE = new ResultsFuture<Void>();
public static final ResultsFuture<Void> NULL_FUTURE = new ResultsFuture<Void>();

static {
NULL_FUTURE.getResultsReceiver().receiveResults(null);
}
private static final Logger logger = Logger.getLogger("org.teiid"); //$NON-NLS-1$

public interface CompletionListener<T> {
void onCompletion(ResultsFuture<T> future);
Expand Down Expand Up @@ -127,7 +131,11 @@ public synchronized boolean isDone() {
private void done() {
synchronized (this.listeners) {
for (CompletionListener<T> completionListener : this.listeners) {
completionListener.onCompletion(this);
try {
completionListener.onCompletion(this);
} catch (Throwable t) {
logger.log(Level.SEVERE, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20031), t);
}
}
this.listeners.clear();
}
Expand All @@ -136,7 +144,11 @@ private void done() {
public void addCompletionListener(CompletionListener<T> listener) {
synchronized (this) {
if (done) {
listener.onCompletion(this);
try {
listener.onCompletion(this);
} catch (Throwable t) {
logger.log(Level.SEVERE, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20031), t);
}
return;
}
synchronized (this.listeners) {
Expand Down
3 changes: 2 additions & 1 deletion client/src/main/java/org/teiid/jdbc/JDBCPlugin.java
Expand Up @@ -59,6 +59,7 @@ public static enum Event implements BundleUtil.Event {
TEIID20027,
TEIID20028,
TEIID20029,
TEIID20030
TEIID20030,
TEIID20031
}
}
6 changes: 5 additions & 1 deletion client/src/main/java/org/teiid/jdbc/MetadataProvider.java
Expand Up @@ -34,7 +34,11 @@ public class MetadataProvider {
protected Map[] metadata;

public MetadataProvider(Map[] metadata) {
this.metadata = metadata;
if (metadata == null) {
this.metadata = new Map[0];
} else {
this.metadata = metadata;
}
}

public Object getValue(int columnIndex, Integer metadataPropertyKey) throws SQLException {
Expand Down
Expand Up @@ -310,7 +310,9 @@ public ResultSetMetaData getMetaData() throws SQLException {

private MetadataResult getMetadataResults() throws SQLException {
if (metadataResults == null) {
if (StatementImpl.SET_STATEMENT.matcher(prepareSql).matches() || StatementImpl.TRANSACTION_STATEMENT.matcher(prepareSql).matches()) {
if (StatementImpl.SET_STATEMENT.matcher(prepareSql).matches()
|| StatementImpl.TRANSACTION_STATEMENT.matcher(prepareSql).matches()
|| StatementImpl.SHOW_STATEMENT.matcher(prepareSql).matches()) {
metadataResults = new MetadataResult();
} else {
try {
Expand Down
3 changes: 2 additions & 1 deletion client/src/main/resources/org/teiid/jdbc/i18n.properties
Expand Up @@ -175,4 +175,5 @@ ambigious_gss_selection=Either configure "java.security.krb5.conf" property or c
no_gss_selection=No KRB5 configuration found. Either configure "java.security.krb5.conf" property or combination of "java.security.krb5.realm" and "java.security.krb5.kdc" properties.
TEIID20029={0} value outside of 32-bit value range. Please set the system property org.teiid.longDatesTimes to true to avoid this error.
TEIID20030=The position cannot be set by a blocking call in asynch mode as the results have not yet been formed.
alias_no_key_entry=The SSL keystore configured does not contain certificate with alias {0}
alias_no_key_entry=The SSL keystore configured does not contain certificate with alias {0}
TEIID20031=Uncaught exception from completion listener.
Expand Up @@ -38,8 +38,8 @@
import org.mockito.Mockito;
import org.teiid.client.DQP;
import org.teiid.client.RequestMessage;
import org.teiid.client.ResultsMessage;
import org.teiid.client.RequestMessage.ResultsMode;
import org.teiid.client.ResultsMessage;
import org.teiid.client.security.LogonResult;
import org.teiid.client.util.ResultsFuture;
import org.teiid.net.ServerConnection;
Expand Down Expand Up @@ -202,6 +202,11 @@ public class TestPreparedStatement {
stmt.setBlob(1, (Blob)null);
}

@Test public void testShowParameterMetadata() throws Exception {
PreparedStatementImpl stmt = getMMPreparedStatement("show plan"); //$NON-NLS-1$
assertEquals(0, stmt.getParameterMetaData().getParameterCount());
}

/**
* Test the <code>addBatch()</code> method of <code>MMPreparedStatement</code>
* using a batch with an empty parameter value list. The test will verify
Expand Down
Expand Up @@ -57,6 +57,7 @@ public class ConnectorManager {

private final String translatorName;
private final String connectionName;
private final String jndiName;
private final List<String> id;

// known requests
Expand All @@ -74,6 +75,15 @@ public ConnectorManager(String translatorName, String connectionName) {
public ConnectorManager(String translatorName, String connectionName, ExecutionFactory<Object, Object> ef) {
this.translatorName = translatorName;
this.connectionName = connectionName;
if (this.connectionName != null) {
if (!this.connectionName.startsWith(JAVA_CONTEXT)) {
jndiName = JAVA_CONTEXT + this.connectionName;
} else {
jndiName = this.connectionName;
}
} else {
jndiName = null;
}
this.executionFactory = ef;
this.id = Arrays.asList(translatorName, connectionName);
}
Expand Down Expand Up @@ -237,11 +247,6 @@ public ExecutionFactory<Object, Object> getExecutionFactory() {
*/
public Object getConnectionFactory() throws TranslatorException {
if (this.connectionName != null) {
String jndiName = this.connectionName;
if (!this.connectionName.startsWith(JAVA_CONTEXT)) {
jndiName = JAVA_CONTEXT + jndiName;
}

try {
InitialContext ic = new InitialContext();
try {
Expand All @@ -250,6 +255,7 @@ public Object getConnectionFactory() throws TranslatorException {
if (!jndiName.equals(this.connectionName)) {
return ic.lookup(this.connectionName);
}
throw e;
}
} catch (Exception e) {
throw new TranslatorException(QueryPlugin.Event.TEIID30481, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30481, this.connectionName));
Expand Down
Expand Up @@ -97,6 +97,7 @@ public static enum Event implements BundleUtil.Event {
TEIID50095,
TEIID50096,
TEIID50097,
TEIID50098
TEIID50098,
TEIID50099
}
}
Expand Up @@ -46,6 +46,7 @@
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ProcessType;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
Expand Down Expand Up @@ -147,7 +148,8 @@ class TeiidAdd extends AbstractAddStepHandler {
protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
resource.getModel().setEmptyObject();
populate(operation, resource.getModel());
if (context.isNormalServer()) {

if (context.getProcessType().equals(ProcessType.STANDALONE_SERVER) && context.isNormalServer()) {
deployResources(context);
}
}
Expand Down
Expand Up @@ -87,6 +87,7 @@
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.jboss.TeiidServiceNames.InvalidServiceNameException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.MetadataStore;
Expand Down Expand Up @@ -1127,7 +1128,12 @@ static void updateServices(OperationContext context, RuntimeVDB vdb,
}
if (rr.removedDs != null) {
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = TeiidServiceNames.dsListenerServiceName(vdb.getVdb().getName(), vdb.getVdb().getVersion(), rr.removedDs);
ServiceName serviceName;
try {
serviceName = TeiidServiceNames.dsListenerServiceName(vdb.getVdb().getName(), vdb.getVdb().getVersion(), rr.removedDs);
} catch (InvalidServiceNameException e) {
return; //the old isn't valid
}
final ServiceController<?> controller = registry.getService(serviceName);
if (controller != null) {
context.removeService(serviceName);
Expand Down
Expand Up @@ -22,6 +22,8 @@
package org.teiid.jboss;

import org.jboss.msc.service.ServiceName;
import org.teiid.core.BundleUtil;
import org.teiid.core.TeiidException;
import org.teiid.deployers.VDBStatusChecker;

public class TeiidServiceNames {
Expand Down Expand Up @@ -49,6 +51,16 @@ public class TeiidServiceNames {
public static ServiceName RESULTSET_CACHE_FACTORY = ServiceName.JBOSS.append("teiid", "infinispan-rs-cache-factory"); //$NON-NLS-1$ //$NON-NLS-2$
public static ServiceName PREPAREDPLAN_CACHE_FACTORY = ServiceName.JBOSS.append("teiid", "infinispan-pp-cache-factory"); //$NON-NLS-1$ //$NON-NLS-2$

public static class InvalidServiceNameException extends TeiidException {

private static final long serialVersionUID = 7555741825606486101L;

public InvalidServiceNameException(BundleUtil.Event code, Throwable t, final String message) {
super(code, t, message);
}

}

public static ServiceName translatorServiceName(String name) {
return ServiceName.of(TRANSLATOR_BASE, name);
}
Expand Down Expand Up @@ -77,7 +89,11 @@ public static ServiceName embeddedTransportServiceName(String name) {
return EMBEDDED_TRANSPORT_BASE.append(name);
}

public static ServiceName dsListenerServiceName(String vdbName, int version, String name) {
return ServiceName.of(DS_LISTENER_BASE, vdbName, String.valueOf(version), VDBStatusChecker.stripContext(name));
public static ServiceName dsListenerServiceName(String vdbName, int version, String name) throws InvalidServiceNameException {
try {
return ServiceName.of(DS_LISTENER_BASE, vdbName, String.valueOf(version), VDBStatusChecker.stripContext(name));
} catch (RuntimeException e) {
throw new InvalidServiceNameException(IntegrationPlugin.Event.TEIID50099, e, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50099, name, vdbName, version));
}
}
}
19 changes: 16 additions & 3 deletions jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
Expand Up @@ -60,6 +60,7 @@
import org.teiid.deployers.VDBRepository;
import org.teiid.deployers.VDBStatusChecker;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.jboss.TeiidServiceNames.InvalidServiceNameException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.index.IndexMetadataRepository;
Expand Down Expand Up @@ -242,10 +243,17 @@ static void addDataSourceListener(
final VDBKey vdbKey,
final String dsName) {
final String jndiName = getJndiName(dsName);
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
ServiceName dsListenerServiceName;
try {
dsListenerServiceName = TeiidServiceNames.dsListenerServiceName(vdbKey.getName(), vdbKey.getVersion(), dsName);
} catch (InvalidServiceNameException e) {
LogManager.logWarning(LogConstants.CTX_RUNTIME, e, e.getMessage());
return;
}
ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
final ServiceName svcName = bindInfo.getBinderServiceName();
DataSourceListener dsl = new DataSourceListener(dsName, svcName, vdbKey);
ServiceBuilder<DataSourceListener> sb = serviceTarget.addService(TeiidServiceNames.dsListenerServiceName(vdbKey.getName(), vdbKey.getVersion(), dsName), dsl);
ServiceBuilder<DataSourceListener> sb = serviceTarget.addService(dsListenerServiceName, dsl);
sb.addDependency(svcName);
sb.addDependency(TeiidServiceNames.VDB_STATUS_CHECKER, VDBStatusChecker.class, dsl.vdbStatusCheckInjector);
sb.setInitialMode(Mode.PASSIVE).install();
Expand Down Expand Up @@ -336,7 +344,12 @@ public void undeploy(final DeploymentUnit deploymentUnit) {
continue;
}

final ServiceController<?> dsService = deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.dsListenerServiceName(deployment.getName(), deployment.getVersion(), dsName));
ServiceController<?> dsService;
try {
dsService = deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.dsListenerServiceName(deployment.getName(), deployment.getVersion(), dsName));
} catch (InvalidServiceNameException e) {
continue;
}
if (dsService != null) {
dsService.setMode(ServiceController.Mode.REMOVE);
}
Expand Down
Expand Up @@ -72,11 +72,11 @@ TEIID50092=Only result produceing procedures are allowed
TEIID50093=Cache factory not found; Make sure the Infinispan based cache factory is correctly configured for Teiid.
TEIID50094=Resultset cache configured without the Infinispan's Cache Container name. Check and provide <resultset-cache infinispan-container="{name}"/> in configuration.
TEIID50095=PreparedPlan cache configured without the Infinispan's Cache Container name. Check and provide <preparedplan-cache infinispan-container="{name}"/> in configuration.
wrong_vdb= Wrong VDB name and/or version supplied, or VDB is not active, or not available.
wrong_vdb=Wrong VDB name and/or version supplied, or VDB is not active, or not available.
TEIID50096=No VDB found with name {0}.{1} or VDB not in ACTIVE status. Please check the supplied values for errors. Use "list-vdbs" to see all the valid deployed VDBs.
failed_to_remove=Failed to undeploy {0}
failed_to_add= Failed to deploy {0}
TEIID50099=Invalid JNDI name "{0}" specified in VDB {1} {2}
# subsystem description
teiid.add = Add the Teiid Subsystem

Expand Down
9 changes: 2 additions & 7 deletions runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java
Expand Up @@ -21,7 +21,6 @@
*/
package org.teiid.odbc;

import java.sql.ParameterMetaData;
import java.util.List;
import java.util.Properties;

Expand Down Expand Up @@ -61,7 +60,7 @@ public interface ODBCClientRemote {
void terminated();

// ParameterDescription (B)
void sendParameterDescription(ParameterMetaData parameterMetaData, int[] paramType);
void sendParameterDescription(int[] paramType);

// BindComplete (B)
void bindComplete();
Expand All @@ -72,11 +71,7 @@ public interface ODBCClientRemote {

// DataRow (B)
// CommandComplete (B)
void sendResults(String sql, ResultSetImpl rs, List<PgColInfo> cols, ResultsFuture<Integer> result, boolean describeRows);

void sendCursorResults(ResultSetImpl rs, List<PgColInfo> cols, ResultsFuture<Integer> result, int rowCount);

void sendPortalResults(String sql, ResultSetImpl rs, List<PgColInfo> cols, ResultsFuture<Integer> result, int rowCount, boolean portal);
void sendResults(String sql, ResultSetImpl rs, List<PgColInfo> cols, ResultsFuture<Integer> result, int rowCount, boolean describeRows);

void sendMoveCursor(ResultSetImpl rs, int rowCount, ResultsFuture<Integer> results);

Expand Down
2 changes: 1 addition & 1 deletion runtime/src/main/java/org/teiid/odbc/ODBCServerRemote.java
Expand Up @@ -33,7 +33,7 @@ public interface ODBCServerRemote {

void prepare(String prepareName, String sql, int[] paramType);

void bindParameters(String bindName, String prepareName, int paramCount, Object[] paramdata, int resultCodeCount, int[] resultColumnFormat);
void bindParameters(String bindName, String prepareName, Object[] paramdata, int resultCodeCount, int[] resultColumnFormat);

void execute(String bindName, int maxrows);

Expand Down

0 comments on commit 3a02d6b

Please sign in to comment.