Skip to content

Commit

Permalink
Merge pull request #3 from rareddy/TEIID-2260
Browse files Browse the repository at this point in the history
Teiid 2260
  • Loading branch information
rareddy committed Oct 11, 2012
2 parents dbf461a + 017fd47 commit 959f0e1
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target
.project
.classpath
bin
build.xml
25 changes: 19 additions & 6 deletions admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* JBoss, Home of Professional Open Source.
/*ode.Id_ADD
* JBoss, Home of Professional Open != Source.
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
Expand Down Expand Up @@ -1099,9 +1099,15 @@ public ModelNode wrap(SessionMetadata session, ModelNode node) {
if (session.getApplicationName() != null) {
node.get(APPLICATION_NAME).set(session.getApplicationName());
}

node.get(CREATED_TIME).set(session.getCreatedTime());
node.get(CLIENT_HOST_NAME).set(session.getClientHostName());
node.get(IP_ADDRESS).set(session.getIPAddress());

if (session.getClientHostName() != null) {
node.get(CLIENT_HOST_NAME).set(session.getClientHostName());
}
if (session.getIPAddress() != null) {
node.get(IP_ADDRESS).set(session.getIPAddress());
}
node.get(LAST_PING_TIME).set(session.getLastPingTime());
node.get(SESSION_ID).set(session.getSessionId());
node.get(USER_NAME).set(session.getUserName());
Expand All @@ -1126,8 +1132,15 @@ public SessionMetadata unwrap(ModelNode node) {
session.setApplicationName(node.get(APPLICATION_NAME).asString());
}
session.setCreatedTime(node.get(CREATED_TIME).asLong());
session.setClientHostName(node.get(CLIENT_HOST_NAME).asString());
session.setIPAddress(node.get(IP_ADDRESS).asString());

if (node.has(CLIENT_HOST_NAME)) {
session.setClientHostName(node.get(CLIENT_HOST_NAME).asString());
}

if (node.has(IP_ADDRESS)) {
session.setIPAddress(node.get(IP_ADDRESS).asString());
}

session.setLastPingTime(node.get(LAST_PING_TIME).asLong());
session.setSessionId(node.get(SESSION_ID).asString());
session.setUserName(node.get(USER_NAME).asString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

Expand All @@ -53,14 +54,25 @@
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.service.SessionServiceException;
import org.teiid.jdbc.ConnectionImpl;
import org.teiid.jdbc.ConnectionProfile;
import org.teiid.jdbc.TeiidDriver;
import org.teiid.jdbc.TeiidSQLException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.socket.AuthenticationType;
import org.teiid.security.SecurityHelper;
import org.teiid.services.SessionServiceImpl;
import org.teiid.transport.*;
import org.teiid.transport.ClientServiceRegistry;
import org.teiid.transport.ClientServiceRegistryImpl;
import org.teiid.transport.LocalServerConnection;
import org.teiid.transport.LogonImpl;
import org.teiid.transport.ODBCSocketListener;
import org.teiid.transport.SocketConfiguration;
import org.teiid.transport.SocketListener;

public class TransportService implements Service<ClientServiceRegistry>, ClientServiceRegistry {
private enum Protocol {teiid, pg};
Expand Down Expand Up @@ -161,7 +173,26 @@ public ClassLoader getCallerClassloader() {
}
else if (protocol == Protocol.pg) {
getVdbRepository().odbcEnabled();
ODBCSocketListener odbc = new ODBCSocketListener(address, this.socketConfig, this.csr, getBufferManagerInjector().getValue(), getMaxODBCLobSizeAllowed(), this.logon);
TeiidDriver driver = new TeiidDriver();
driver.setEmbeddedProfile(new ConnectionProfile() {
@Override
public ConnectionImpl connect(String url, Properties info) throws TeiidSQLException {
try {
LocalServerConnection sc = new LocalServerConnection(info, true){
@Override
protected ClientServiceRegistry getClientServiceRegistry() {
return csr;
}
};
return new ConnectionImpl(sc, info, url);
} catch (CommunicationException e) {
throw TeiidSQLException.create(e);
} catch (ConnectionException e) {
throw TeiidSQLException.create(e);
}
}
});
ODBCSocketListener odbc = new ODBCSocketListener(address, this.socketConfig, this.csr, getBufferManagerInjector().getValue(), getMaxODBCLobSizeAllowed(), this.logon, driver);
odbc.setAuthenticationType(this.sessionService.getAuthenticationType());
this.socketListener = odbc;
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50037, address.getHostName(), String.valueOf(address.getPort()), (sslEnabled?"ON":"OFF"), authenticationDomains)); //$NON-NLS-1$ //$NON-NLS-2$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public class ODBCSocketListener extends SocketListener {
private TeiidDriver driver;
private ILogon logonService;

public ODBCSocketListener(InetSocketAddress address, SocketConfiguration config, final ClientServiceRegistryImpl csr, StorageManager storageManager, int maxLobSize, ILogon logon) {
public ODBCSocketListener(InetSocketAddress address, SocketConfiguration config, final ClientServiceRegistryImpl csr, StorageManager storageManager, int maxLobSize, ILogon logon, TeiidDriver driver) {
//the clientserviceregistry isn't actually used by ODBC
super(address, config, csr, storageManager);
this.maxLobSize = maxLobSize;
this.driver = new TeiidDriver();
this.driver = driver;
this.logonService = logon;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ public void start() throws Exception {
addr = new InetSocketAddress(0);
config.setBindAddress(addr.getHostName());
config.setPortNumber(addr.getPort());
odbcTransport = new ODBCSocketListener(addr, config, Mockito.mock(ClientServiceRegistryImpl.class), BufferManagerFactory.getStandaloneBufferManager(), 100000, Mockito.mock(ILogon.class));
odbcTransport.setMaxBufferSize(1000); //set to a small size to ensure buffering over the limit works
FakeServer server = new FakeServer(true);
odbcTransport = new ODBCSocketListener(addr, config, Mockito.mock(ClientServiceRegistryImpl.class), BufferManagerFactory.getStandaloneBufferManager(), 100000, Mockito.mock(ILogon.class), server.getDriver());
odbcTransport.setMaxBufferSize(1000); //set to a small size to ensure buffering over the limit works

server.setUseCallingThread(false);
server.deployVDB("parts", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");

odbcTransport.setDriver(server.getDriver());
}

public void stop() {
Expand Down

0 comments on commit 959f0e1

Please sign in to comment.