Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge all tooling into one new repository #1

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) [2023] [Jiri Novotny <jnovotny@redhat.com>]
Copyright (c) [2023] [Jiri Novotny <kulisek.novotny@gmail.com>, Ondrej Babec <ond.babec@gmail.com>]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Empty file added README
Empty file.
2 changes: 2 additions & 0 deletions database-manipulation-tool-schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# dmt-schema
Library with dmt objects representing database entries (rows)
77 changes: 77 additions & 0 deletions database-manipulation-tool-schema/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>database-manipulation-tool-schema</artifactId>
<version>${project.parent.version}</version>
<name>database-manipulation-tool-schema</name>
<description>Library with database manipulation tool objects representing database entries (rows)</description>


<parent>
<artifactId>database-performance-hub</artifactId>
<groupId>io.skodjob</groupId>
<version>1.0.0</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.1</version>
</dependency>
</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.skodjob.dmt.schema;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class App
{
public static void main( String[] args )
{
System.out.println( "TEST RUN FOR DMT SCHEMA" );
DatabaseEntry entry = new DatabaseEntry("TestTableName", "name");
entry.addColumnEntry(new DatabaseColumnEntry("testValue1", "name", "testDataType1"));
entry.addColumnEntry(new DatabaseColumnEntry("testValue2", "name2", "testDataType2"));
try {
var str = new ObjectMapper().writeValueAsString(entry);
System.out.println("STRING: " + str);
var parsedString = new ObjectMapper().readValue(str, DatabaseEntry.class);
System.out.println("DATABASE_ENTRY: " + parsedString);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
System.out.println( "TEST RUN FOR DMT LOAD RESULT SCHEMA" );
LoadResult loadResult = new LoadResult(1000, 100, 950);
try {
var str = new ObjectMapper().writeValueAsString(loadResult);
System.out.println("STRING: " + str);
var parsedString = new ObjectMapper().readValue(str, LoadResult.class);
System.out.println("LOAD_RESULT: " + parsedString);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package io.skodjob.dmt.schema;

import java.util.Objects;

public final class DatabaseColumnEntry {
private String value;
private String columnName;
private String dataType;

public DatabaseColumnEntry(String value, String columnName, String dataType) {
this.value = value;
this.columnName = columnName;
this.dataType = dataType;
}

public DatabaseColumnEntry() {
this.value = "UNDEFINED";
this.columnName = "UNDEFINED";
this.dataType = "UNDEFINED";
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public String getColumnName() {
return columnName;
}

public void setColumnName(String columnName) {
this.columnName = columnName;
}

public String getDataType() {
return dataType;
}

public void setDataType(String dataType) {
this.dataType = dataType;
}

@Override
public String toString() {
return "DatabaseColumnEntry{" +
"value='" + value + '\'' +
", columnName='" + columnName + '\'' +
", dataType='" + dataType + '\'' +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DatabaseColumnEntry entry = (DatabaseColumnEntry) o;
return Objects.equals(value, entry.value) && Objects.equals(columnName, entry.columnName) && Objects.equals(dataType, entry.dataType);
}

@Override
public int hashCode() {
return Objects.hash(value, columnName, dataType);
}

public String value() {
return value;
}

public String columnName() {
return columnName;
}

public String dataType() {
return dataType;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package io.skodjob.dmt.schema;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class DatabaseEntry {

private List<DatabaseColumnEntry> columnEntries;
private String name;
private String primary;

public DatabaseEntry(List<DatabaseColumnEntry> columnEntries, String name, String primary) {
this.columnEntries = columnEntries;
this.name = name;
this.primary = primary;
}

public DatabaseEntry(String name, String primary) {
this.name = name;
this.primary = primary;
columnEntries = new ArrayList<>();
}

public DatabaseEntry() {
this.name = "UNDEFINED";
this.primary = "UNDEFINED";
columnEntries = new ArrayList<>();
}

public List<DatabaseColumnEntry> getColumnEntries() {
return columnEntries;
}

public void setColumnEntries(List<DatabaseColumnEntry> columnEntries) {
this.columnEntries = columnEntries;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getPrimary() {
return primary;
}

public void setPrimary(String primary) {
this.primary = primary;
}

public void addColumnEntry(DatabaseColumnEntry columnEntry) {
columnEntries.add(columnEntry);
}


/**
* @return DatabaseColumnEntry which is the primary in this DatabaseEntry
*/
@JsonIgnore
public DatabaseColumnEntry getPrimaryColumnEntry() {
String primaryColumnName = getPrimary();
for (DatabaseColumnEntry columnEntry : columnEntries) {
if (columnEntry.columnName().equals(primaryColumnName)) {
return columnEntry;
}
}
return null;
}

@Override
public String toString() {
return "DatabaseEntry{" +
"columnEntries=" + columnEntries +
", name='" + name + '\'' +
", primary='" + primary + '\'' +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DatabaseEntry that = (DatabaseEntry) o;
return columnEntries.equals(that.columnEntries);
}

@Override
public int hashCode() {
return Objects.hash(columnEntries);
}

public String toJsonString() throws JsonProcessingException {
return new ObjectMapper().writeValueAsString(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package io.skodjob.dmt.schema;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Objects;

/**
* Model class for time results from load generation in DMT. Every property is in milliseconds.
*/
public class LoadResult {
long totalTime;
long lastExecutorStarted;
long LastExecutorFinished;

/**
* @param totalTime Total time it took to generate the queries/requests and to send it through the client/JDBC to database.
* @param lastExecutorStarted Time it took to start executing queries/request on all connections without the data generation.
* @param lastExecutorFinished Time it took to finish executing queries/requests on all connections without the data generation.
*/
public LoadResult(long totalTime, long lastExecutorStarted, long lastExecutorFinished) {
this.totalTime = totalTime;
this.lastExecutorStarted = lastExecutorStarted;
this.LastExecutorFinished = lastExecutorFinished;
}

public LoadResult() {
this.totalTime = 0;
this.LastExecutorFinished = 0;
this.lastExecutorStarted = 0;
}

public long getTotalTime() {
return totalTime;
}

public void setTotalTime(long totalTime) {
this.totalTime = totalTime;
}

public long getLastExecutorStarted() {
return lastExecutorStarted;
}

public void setLastExecutorStarted(long lastExecutorStarted) {
this.lastExecutorStarted = lastExecutorStarted;
}

public long getLastExecutorFinished() {
return LastExecutorFinished;
}

public void setLastExecutorFinished(long lastExecutorFinished) {
this.LastExecutorFinished = lastExecutorFinished;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LoadResult that = (LoadResult) o;
return totalTime == that.totalTime && lastExecutorStarted == that.lastExecutorStarted && LastExecutorFinished == that.LastExecutorFinished;
}

@Override
public int hashCode() {
return Objects.hash(totalTime, lastExecutorStarted, LastExecutorFinished);
}

public String toJsonString() throws JsonProcessingException {
return new ObjectMapper().writeValueAsString(this);
}

@Override
public String toString() {
return "LoadResult{" +
"totalTime=" + totalTime +
", lastExecutorStarted=" + lastExecutorStarted +
", LastExecutorFinished=" + LastExecutorFinished +
'}';
}
}
Loading