Skip to content

Commit

Permalink
updated to plugin architecture, minor reformatting and adjustment of …
Browse files Browse the repository at this point in the history
…header files
  • Loading branch information
datomo committed Feb 9, 2023
1 parent ad1eb1f commit d14f78e
Show file tree
Hide file tree
Showing 17 changed files with 165 additions and 184 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,16 @@

package org.polypheny.db.postgres;

import static org.junit.Assert.assertEquals;

import com.google.common.collect.ImmutableList;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import lombok.extern.slf4j.Slf4j;
import org.junit.AfterClass;
import org.junit.BeforeClass;
Expand All @@ -28,13 +37,9 @@
import org.polypheny.db.catalog.exceptions.UnknownSchemaException;
import org.polypheny.db.catalog.exceptions.UnknownTableException;

import java.sql.*;
import java.util.Properties;

import static org.junit.Assert.assertEquals;

//import static org.polypheny.db.postgresql.PGInterfaceInboundCommunicationHandler.ctx;


/**
* Tests the implementation of the PGInterface --> simulates a client that connects via JDBC
*/
Expand Down Expand Up @@ -68,6 +73,7 @@ public static void start() throws SQLException {

}


/**
* Cleans up after the tests
*
Expand Down Expand Up @@ -134,6 +140,7 @@ public void testIfDMLandDDLandDQLIsExecuted() throws SQLException {
}
}


/**
* Tests if a prepared statement is correctly executed if the PREPARE and EXECUTE statement are sent seperately
*
Expand Down Expand Up @@ -186,6 +193,7 @@ public void testPreparedAndExecuteInOnePart() throws SQLException {
}
}


/**
* This feature is not yet supported, but it tests if prepared statement are executed correctly using the JDBC framework
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ configurations {
}

dependencies {
implementation project(":core")
implementation project(":monitoring")
compileOnly project(":core")
compileOnly project(":monitoring")

////// NETTY
// https://mvnrepository.com/artifact/io.netty/netty-all
Expand All @@ -23,28 +23,6 @@ dependencies {
}


sourceSets {
main {
java {
srcDirs = ["src/main/java"]
outputDir = file(project.buildDir.absolutePath + "/classes")
}
resources {
srcDirs = ["src/main/resources"]
}
output.resourcesDir = file(project.buildDir.absolutePath + "/classes")
}
test {
java {
srcDirs = ["src/test/java"]
outputDir = file(project.buildDir.absolutePath + "/test-classes")
}
resources {
srcDirs = ["src/test/resources"]
}
output.resourcesDir = file(project.buildDir.absolutePath + "/test-classes")
}
}


/**
Expand All @@ -68,3 +46,7 @@ java {
withJavadocJar()
withSourcesJar()
}

licensee {
allow('Apache-2.0')
}
27 changes: 27 additions & 0 deletions plugins/postgresql-interface/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Copyright 2019-2023 The Polypheny Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

pluginVersion = 0.0.1

pluginId = postgres-interface
pluginClass = org.polypheny.db.postgresql.PostgresqlInterfacePlugin
pluginProvider = The Polypheny Project
pluginDependencies =
pluginUrlPath =
pluginCategories = interface
pluginPolyDependencies =
pluginIsSystemComponent = false
pluginIsUiVisible = true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,31 +19,34 @@

import com.google.common.collect.ImmutableList;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.StatusService;
import org.polypheny.db.catalog.Catalog.QueryLanguage;
import org.polypheny.db.iface.Authenticator;
import org.polypheny.db.iface.QueryInterface;
import org.polypheny.db.information.InformationGroup;
import org.polypheny.db.information.InformationManager;
import org.polypheny.db.information.InformationPage;
import org.polypheny.db.information.InformationTable;
import org.polypheny.db.languages.QueryLanguage;
import org.polypheny.db.transaction.TransactionManager;
import org.polypheny.db.util.Util;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;


/**
* First point of contact for the PGInterface, setting changes from the UI are handled here
Expand Down Expand Up @@ -161,6 +164,12 @@ protected void reloadSettings( List<String> updatedSettings ) {
}


@Override
public void languageChange() {

}


private class MonitoringPage {
//TODO(FF): vergliiche met anderne interfaces (zeigt infos em ui aah) --> sött glaubs ok sii??

Expand Down Expand Up @@ -201,7 +210,7 @@ public void update() {
DecimalFormat df = new DecimalFormat( "0.0", symbols );
statementsTable.reset();
for ( Map.Entry<QueryLanguage, AtomicLong> entry : statementCounters.entrySet() ) {
statementsTable.addRow( entry.getKey().name(), df.format( total == 0 ? 0 : (entry.getValue().longValue() / total) * 100 ) + " %", entry.getValue().longValue() );
statementsTable.addRow( entry.getKey().getSerializedName(), df.format( total == 0 ? 0 : (entry.getValue().longValue() / total) * 100 ) + " %", entry.getValue().longValue() );
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,9 +18,8 @@

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;

import java.util.LinkedHashMap;
import lombok.extern.slf4j.Slf4j;

/**
* Writes and sends error messages to the client
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,11 +18,10 @@

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.transaction.TransactionManager;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.transaction.TransactionManager;

/**
* Manages all incoming communication, not a handler from netty, but called by one
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,13 +17,17 @@
package org.polypheny.db.postgresql;

import io.netty.channel.ChannelHandlerContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.transaction.Statement;
import org.polypheny.db.type.PolyType;

import java.util.*;

/**
* Contains information for prepared queries, and also methods to handle the information
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,9 @@
package org.polypheny.db.postgresql;

import io.netty.channel.ChannelHandlerContext;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.PolyImplementation;
import org.polypheny.db.algebra.AlgRoot;
Expand All @@ -28,6 +31,7 @@
import org.polypheny.db.catalog.exceptions.UnknownSchemaException;
import org.polypheny.db.catalog.exceptions.UnknownUserException;
import org.polypheny.db.config.RuntimeConfig;
import org.polypheny.db.languages.QueryLanguage;
import org.polypheny.db.languages.QueryParameters;
import org.polypheny.db.nodes.Node;
import org.polypheny.db.processing.Processor;
Expand All @@ -37,10 +41,6 @@
import org.polypheny.db.transaction.TransactionException;
import org.polypheny.db.transaction.TransactionManager;

import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.List;


/**
* Handles all queries from the extended query cycle - "sends" them to polypheny and processes answer
Expand Down Expand Up @@ -116,7 +116,7 @@ public void sendQueryToPolypheny() {
}

//get algRoot
Processor sqlProcessor = statement.getTransaction().getProcessor( Catalog.QueryLanguage.SQL );
Processor sqlProcessor = statement.getTransaction().getProcessor( QueryLanguage.from( "sql" ) );
Node sqlNode = sqlProcessor.parse( query ).get( 0 );
QueryParameters parameters = new QueryParameters( query, Catalog.NamespaceType.RELATIONAL );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,11 +18,10 @@

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import java.util.ArrayList;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.transaction.TransactionManager;

import java.util.ArrayList;

/**
* Forwards the message from the "netty flow" to the internal structure
*/
Expand Down
Loading

0 comments on commit d14f78e

Please sign in to comment.