Skip to content

Commit

Permalink
Remove unused code and various small improvements (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens authored Dec 20, 2024
1 parent e86ad3d commit 21b64d6
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.experimental.NonFinal;
import lombok.experimental.SuperBuilder;
Expand Down Expand Up @@ -122,24 +121,6 @@ public List<Long> getConstraintIds() {
}


@RequiredArgsConstructor
public static class PrimitiveCatalogTable {

public final String tableCat;
public final String tableSchem;
public final String tableName;
public final String tableType;
public final String remarks;
public final String typeCat;
public final String typeSchem;
public final String typeName;
public final String selfReferencingColName;
public final String refGeneration;
public final String owner;

}


@Override
public String toString() {
return "LogicalTable{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ public AlgNode prepareView( AlgCluster cluster ) {


public void prepareView( AlgNode viewLogicalRoot, AlgCluster algCluster ) {
if ( viewLogicalRoot instanceof AbstractAlgNode ) {
((AbstractAlgNode) viewLogicalRoot).setCluster( algCluster );
if ( viewLogicalRoot instanceof AbstractAlgNode algNode ) {
algNode.setCluster( algCluster );
}
if ( viewLogicalRoot instanceof BiAlg ) {
prepareView( ((BiAlg) viewLogicalRoot).getLeft(), algCluster );
prepareView( ((BiAlg) viewLogicalRoot).getRight(), algCluster );
} else if ( viewLogicalRoot instanceof SingleAlg ) {
prepareView( ((SingleAlg) viewLogicalRoot).getInput(), algCluster );
if ( viewLogicalRoot instanceof BiAlg biAlg ) {
prepareView( biAlg.getLeft(), algCluster );
prepareView( biAlg.getRight(), algCluster );
} else if ( viewLogicalRoot instanceof SingleAlg singleAlg ) {
prepareView( singleAlg.getInput(), algCluster );
}
if ( viewLogicalRoot instanceof LogicalRelViewScan ) {
prepareView( ((LogicalRelViewScan) viewLogicalRoot).getAlgNode(), algCluster );
if ( viewLogicalRoot instanceof LogicalRelViewScan logicalRelViewScan ) {
prepareView( logicalRelViewScan.getAlgNode(), algCluster );
}
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/polypheny/db/docker/AutoDocker.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static AutoDocker getInstance() {

private void updateStatus( String newStatus ) {
status = newStatus;
log.info( "AutoDocker: " + newStatus );
log.info( "AutoDocker: {}", newStatus );
}


Expand Down Expand Up @@ -243,7 +243,7 @@ public void doAutoConnect() {
try {
handshake = DockerSetupHelper.reconnectToInstance( maybeDockerInstance.get().getKey() );
} catch ( DockerUserException e ) {
log.info( "AutoDocker: Reconnect failed: " + e );
log.info( "AutoDocker: Reconnect failed: {}", String.valueOf( e ) );
updateStatus( "error: " + e.getMessage() );
throw new DockerUserException( e.getMessage() );
}
Expand All @@ -255,7 +255,7 @@ public void doAutoConnect() {
}
handshake = res.get();
} catch ( DockerUserException e ) {
log.info( "AutoDocker: Setup failed: " + e );
log.info( "AutoDocker: Setup failed: {}", String.valueOf( e ) );
updateStatus( "setup failed: " + e.getMessage() );
throw e;
}
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/org/polypheny/db/docker/DockerContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public Optional<Integer> getExposedPort( int port ) {
}
throw new IOException();
} catch ( IOException e ) {
log.error( "Failed to retrieve list of ports for container " + containerId );
log.error( "Failed to retrieve list of ports for container {}", containerId );
return Optional.empty();
}
}
Expand All @@ -163,7 +163,7 @@ private Thread pipe( InputStream in, OutputStream out, String name ) {
return;
}
}
log.error( "Pipe " + name, e );
log.error( "Pipe {}", name, e );
}
}, name );
t.start();
Expand All @@ -178,7 +178,7 @@ private void startProxyForConnection( DockerInstance dockerInstance, Socket loca
} catch ( IOException e ) {
if ( e instanceof SocketException || e instanceof EOFException ) {
// ignore
} else if ( e instanceof TlsFatalAlert && ((TlsFatalAlert) e).getAlertDescription() == AlertDescription.handshake_failure ) {
} else if ( e instanceof TlsFatalAlert alert && alert.getAlertDescription() == AlertDescription.handshake_failure ) {
// ignore
} else {
log.info( "startProxyForConnection", e );
Expand All @@ -189,8 +189,8 @@ private void startProxyForConnection( DockerInstance dockerInstance, Socket loca
OutputStream remoteOut = client.getOutputStream().get();
try {
remoteOut.write( (containerId + ":" + port + "\n").getBytes( StandardCharsets.UTF_8 ) );
Thread copyToRemote = pipe( local.getInputStream(), remoteOut, String.format( "polypheny => %s", uniqueName ) );
Thread copyFromRemote = pipe( client.getInputStream().get(), local.getOutputStream(), String.format( "polypheny <= %s", uniqueName ) );
Thread copyToRemote = pipe( local.getInputStream(), remoteOut, String.format( "polypheny -> %s", uniqueName ) );
Thread copyFromRemote = pipe( client.getInputStream().get(), local.getOutputStream(), String.format( "polypheny <- %s", uniqueName ) );
new Thread( () -> {
while ( true ) {
try {
Expand Down Expand Up @@ -224,7 +224,7 @@ private ServerSocket startServer( int port ) {
startProxyForConnection( dockerInstance, local, port );
} catch ( IOException e ) {
if ( !(e instanceof SocketException) || !e.getMessage().equals( "Socket closed" ) ) {
log.info( "Server Socket for port " + port + " closed", e );
log.info( "Server Socket for port {} closed", port, e );
}
synchronized ( this ) {
Util.closeNoThrow( proxies.remove( port ) );
Expand Down Expand Up @@ -257,7 +257,7 @@ public boolean waitTillStarted( Supplier<Boolean> isReadySupplier, long maxTimeo
StopWatch stopWatch = new StopWatch();
stopWatch.start();
boolean isStarted = isReadySupplier.get();
while ( !isStarted && (stopWatch.getTime() < maxTimeoutMs) ) {
while ( !isStarted && (stopWatch.getDuration().toMillis() < maxTimeoutMs) ) {
try {
TimeUnit.MILLISECONDS.sleep( 500 );
} catch ( InterruptedException e ) {
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/polypheny/db/docker/DockerInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private enum Status {
try {
checkConnection();
} catch ( IOException e ) {
log.error( "Could not connect to docker instance " + host.alias() + ": " + e.getMessage() );
log.error( "Could not connect to docker instance {}: {}", host.alias(), e.getMessage() );
}
}

Expand Down Expand Up @@ -117,7 +117,7 @@ private void handleNewDockerInstance() throws IOException {
try {
this.client.deleteContainer( containerInfo.getUuid() );
} catch ( IOException e ) {
log.error( "Failed to delete container " + containerInfo.getUuid(), e );
log.error( "Failed to delete container {}", containerInfo.getUuid(), e );
}
}
);
Expand Down Expand Up @@ -170,7 +170,7 @@ public void reconnect() {
}
checkConnection();
} catch ( IOException e ) {
log.info( "Failed to reconnect: " + e );
log.info( "Failed to reconnect: {}", String.valueOf( e ) );
}
}
}
Expand Down Expand Up @@ -231,9 +231,9 @@ void destroyContainer( DockerContainer container ) {
client.deleteContainer( container.getContainerId() );
} catch ( IOException e ) {
if ( e.getMessage().startsWith( "No such container" ) ) {
log.info( "Cannot delete container: No container with UUID " + container.getContainerId() );
log.info( "Cannot delete container: No container with UUID {}", container.getContainerId() );
} else {
log.error( "Failed to delete container with UUID " + container.getContainerId(), e );
log.error( "Failed to delete container with UUID {}", container.getContainerId(), e );
}
}
}
Expand Down Expand Up @@ -283,7 +283,7 @@ Optional<HandshakeInfo> updateConfig( String hostname, String alias, String regi
this.host = newHost;
checkConnection();
} catch ( IOException e ) {
log.info( "Failed to connect to '" + hostname + "': " + e.getMessage() );
log.info( "Failed to connect to '{}': {}", hostname, e.getMessage() );
return Optional.of( HandshakeManager.getInstance().newHandshake( newHost, null, true ) );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static void removeDockerInstance( int id ) {
throw new DockerUserException( "Docker instance still in use by at least one container" );
}
} catch ( IOException e ) {
log.info( "Failed to retrieve list of docker containers " + e );
log.info( "Failed to retrieve list of docker containers {}", String.valueOf( e ) );
}

HandshakeManager.getInstance().cancelHandshakes( dockerInstance.getHost().hostname() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ boolean doHandshake() {
return false; // Prevents a handshake successful message to be printed when cancelled
}
} else {
log.error( "Server " + hostname + " has send an invalid authentication value, aborting handshake" );
log.error( "Server {} has send an invalid authentication value, aborting handshake", hostname );
// On purpose not NOT_RUNNING, because it could be an attack attempt. This forces regeneration
// of the psk, so the attacker has one chance to guess. The more likely explanation is pasting
// an old command, hence this error message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import io.activej.serializer.SerializerFactory;
import io.activej.serializer.def.SimpleSerializerDef;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.config.RuntimeConfig;
Expand All @@ -47,7 +45,6 @@ static <C extends Class<T>, T> BinarySerializer<T> buildSerializer( C clazz ) {
.create( CLASS_LOADER, clazz );
}

Map<Class<?>, BinarySerializer<?>> cache = new HashMap<>();
int BUFFER_SIZE = RuntimeConfig.SERIALIZATION_BUFFER_SIZE.getInteger();
Charset CHARSET = Util.getDefaultCharset();

Expand Down

0 comments on commit 21b64d6

Please sign in to comment.