Skip to content

Commit 5fa601e

Browse files
authored
Move DRA code into main repo, and README updates for OGHO compliance (#768)
--------- Signed-off-by: Mark Nelson <mark.x.nelson@oracle.com>
1 parent 489bc45 commit 5fa601e

File tree

80 files changed

+7223
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+7223
-10
lines changed

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@ deliver agile application development practices. However, the data-driven nature
1313
of enterprise applications has made building, deploying, and maintaining
1414
microservices complex.
1515

16-
| Sample | Description |
17-
| :----- | :---------- |
18-
| [`grabdish`](./grabdish) | Mobile food delivery application sample code |
19-
20-
## Resources
21-
22-
* [Building Microservices with Oracle Converged Database Workshop][Workshop]
23-
* [Blogs][Blogs]
16+
## Documentation
17+
18+
* [Oracle Backend for Spring Boot and Microservices](http://bit.ly/oraclespringboot)
19+
* [Oracle Backend for Parse Platform](https://bit.ly/oraclembaas) (Oracle's "MEAN" stack)
20+
* [CloudBank Live Lab](https://bit.ly/CloudBankOnOBaaS) - Building an App with Spring Boot
21+
and Mobile APIs with Oracle Database and Kubernetes
22+
* [Kubernetes for DBAs Live Lab](http://bit.ly/KubernetesForDBAs)
23+
<!-- * [Oracle Spring Boot Starters](https://oracle.github.io/microservices-datadriven/spring/starters/) -->
24+
* [Data Refactoring Advisor](./data-refactoring-advisor/README.md)
25+
* [Data Refactoring Advisor for Migrating a Monolith to Microservices Live Lab](https://bit.ly/datarefactoringadvisor)
26+
* [Building Microservices with Oracle Converged Database Live Lab][Workshop]
27+
* [Read our blogs](https://oracle.github.io/microservices-datadriven/spring/blogs)
28+
* [Sample code for Oracle Transactional Event Queues](./code-teq)
2429

2530
## Contributing
2631

@@ -32,7 +37,7 @@ Please consult the [security guide](./SECURITY.md) for our responsible security
3237

3338
## License
3439

35-
Copyright (c) 2021, 2023 Oracle and/or its affiliates.
40+
Copyright (c) 2021, 2023, Oracle and/or its affiliates.
3641

3742
Licensed under the Universal Permissive License v 1.0 as shown at <https://oss.oracle.com/licenses/upl>.
3843

@@ -41,4 +46,4 @@ Licensed under the Universal Permissive License v 1.0 as shown at <https://oss.o
4146
[Workshops]: https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/livelabs-workshop-cards?p100_role=12&p100_focus_area=35&me=126
4247
[DRC]: https://developer.oracle.com
4348
[Workshop]: https://bit.ly/bettermicroservices
44-
[Blogs]: https://blogs.oracle.com/developers/authors/Blog-Author/CORE18EB69239F2845558809929771DB8EFA/paulparkinson
49+

data-refactoring-advisor/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Data Refactoring Advisor
2+
3+
Data Refactoring Advisor, which is currently in development, is a tool to help refactor monolithic
4+
data stores for microservices.
5+
6+
Microservices typically have their own data stores (domain, bounded context) and to communicate only by APIs.
7+
The data store is part of the service’s implementation and is private.
8+
Data is exposed indirectly by the service’s API.
9+
This helps to promote loose coupling and strong contracts.
10+
11+
Monolithic applications typically have a large, shared database, which makes it easy for different parts
12+
of the application to access whatever data they need, but tends to create increasingly complex interdependencies,
13+
makes it difficult to refactor the application or the data model, and obscures data (domain) ownership.
14+
15+
Data Refactoring Advisor helps identify bounded contexts based on how the data are used.
16+
It collects information about actual usage patterns (e.g. how often tables are joined) in SQL Tuning Sets,
17+
calculates the affinity of each pair of tables based on usage,
18+
and uses the InfoMap algorithm (in Graph Studio) to identify communities/clusters.
19+
20+
The diagram below shows the basic flow:
21+
22+
![](./dra-flowchart.png)
23+
24+
More information can be found in the [Data Refactoring Advisor for Migrating a Monolith to Microservices](https://bit.ly/datarefactoringadvisor) Live Lab.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Copyright (c) 2023, Oracle and/or its affiliates. -->
3+
<!-- Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/ -->
4+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
<parent>
8+
<groupId>org.springframework.boot</groupId>
9+
<artifactId>spring-boot-starter-parent</artifactId>
10+
<version>3.0.6</version>
11+
<relativePath/> <!-- lookup parent from repository -->
12+
</parent>
13+
<groupId>com.example</groupId>
14+
<artifactId>datarefactoringadvisorcode</artifactId>
15+
<version>0.0.1-SNAPSHOT</version>
16+
<name>datarefactoringadvisor</name>
17+
<description>Demo project for Spring Boot</description>
18+
<properties>
19+
<java.version>17</java.version>
20+
</properties>
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-web</artifactId>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-devtools</artifactId>
30+
<scope>runtime</scope>
31+
<optional>true</optional>
32+
</dependency>
33+
<!-- Oracle JDBC driver -->
34+
<dependency>
35+
<groupId>com.oracle.database.jdbc</groupId>
36+
<artifactId>ojdbc8</artifactId>
37+
<scope>runtime</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-starter-test</artifactId>
42+
<scope>test</scope>
43+
</dependency>
44+
45+
<!-- Spring data JPA, default tomcat pool, exclude it -->
46+
<dependency>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-starter-data-jpa</artifactId>
49+
<exclusions>
50+
<exclusion>
51+
<groupId>org.apache.tomcat</groupId>
52+
<artifactId>tomcat-jdbc</artifactId>
53+
</exclusion>
54+
</exclusions>
55+
</dependency>
56+
57+
58+
59+
<!-- HikariCP connection pool -->
60+
<dependency>
61+
<groupId>com.zaxxer</groupId>
62+
<artifactId>HikariCP</artifactId>
63+
<version>2.6.0</version>
64+
</dependency>
65+
66+
<dependency>
67+
<groupId>com.oracle.database.security</groupId>
68+
<artifactId>oraclepki</artifactId>
69+
<version>21.1.0.0</version>
70+
</dependency>
71+
72+
<dependency>
73+
<groupId>com.oracle.database.security</groupId>
74+
<artifactId>osdt_core</artifactId>
75+
<version>21.1.0.0</version>
76+
</dependency>
77+
78+
<dependency>
79+
<groupId>com.oracle.database.security</groupId>
80+
<artifactId>osdt_cert</artifactId>
81+
<version>21.1.0.0</version>
82+
</dependency>
83+
84+
<dependency>
85+
<groupId>org.projectlombok</groupId>
86+
<artifactId>lombok</artifactId>
87+
<version>1.18.26</version>
88+
</dependency>
89+
90+
<!-- Community Detection -->
91+
<dependency>
92+
<groupId>com.oracle.database.graph</groupId>
93+
<artifactId>opg-client</artifactId>
94+
<version>23.2.0</version>
95+
</dependency>
96+
97+
<!-- https://mvnrepository.com/artifact/org.json/json -->
98+
<dependency>
99+
<groupId>org.json</groupId>
100+
<artifactId>json</artifactId>
101+
<version>20230618</version>
102+
</dependency>
103+
104+
105+
</dependencies>
106+
107+
<repositories>
108+
<repository>
109+
<id>spoofax</id>
110+
<url>https://artifacts.metaborg.org/content/repositories/releases/
111+
</url>
112+
</repository>
113+
</repositories>
114+
115+
<build>
116+
<plugins>
117+
<plugin>
118+
<groupId>org.springframework.boot</groupId>
119+
<artifactId>spring-boot-maven-plugin</artifactId>
120+
</plugin>
121+
</plugins>
122+
</build>
123+
124+
</project>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.dra;
5+
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.boot.CommandLineRunner;
8+
import org.springframework.boot.SpringApplication;
9+
import org.springframework.boot.autoconfigure.SpringBootApplication;
10+
import org.springframework.jdbc.core.JdbcTemplate;
11+
import org.springframework.jdbc.core.RowMapper;
12+
13+
import com.example.dra.entity.Tables18NodesEntity;
14+
import com.example.dra.service.CreateSQLTuningSetService;
15+
16+
17+
@SpringBootApplication
18+
public class DraApplication implements CommandLineRunner{
19+
20+
@Autowired
21+
private JdbcTemplate jdbcTemplate;
22+
23+
@Autowired
24+
CreateSQLTuningSetService createSQLTuningSetDao;
25+
26+
public static void main(String[] args) {
27+
System.out.println("In main of DraApplication");
28+
SpringApplication.run(DraApplication.class, args);
29+
}
30+
31+
public void run(String... args) throws Exception {
32+
33+
// System.out.println("In run method of DataRefactoringAdvisorApplication");
34+
// jdbcTemplate.query("SELECT * FROM TABLES_18_NODES", (RowMapper<Object>) (rs, i) -> new TABLES_18_NODES(rs.getString("TABLE_NAME")))
35+
// .forEach(System.out::println);
36+
37+
// Tables18NodesEntity tables18Nodes =createSQLTuningSetDao.createSqlSet("abc");
38+
39+
// System.out.println(tables18Nodes);
40+
}
41+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.dra;
5+
6+
import java.sql.*;
7+
8+
public class SQLTuneExample {
9+
public static void main(String[] args) {
10+
String url = "jdbc:oracle:thin:@medicalrecordsdb_tp?tns_admin=C:/Oracle/atp";
11+
String username = "ADMIN";
12+
String password = "xxx";
13+
14+
Connection connection = null;
15+
CallableStatement callableStatement = null;
16+
17+
try {
18+
// Establishing a connection to the database
19+
connection = DriverManager.getConnection(url, username, password);
20+
21+
// Creating a CallableStatement for invoking DBMS_SQLTUNE
22+
callableStatement = connection.
23+
prepareCall("CALL DBMS_SQLTUNE.create_sqlset(sqlset_name => '4STS')");
24+
25+
/* // Setting the SQL tuning task XML
26+
String sqlTuningTaskXml = "<task><sqltext>SELECT * FROM your_table</sqltext></task>";
27+
callableStatement.setString(1, sqlTuningTaskXml);
28+
29+
// Setting the task name
30+
String taskName = "SQL_TUNING_TASK";
31+
callableStatement.setString(2, taskName);*/
32+
33+
// Executing the import tuning task procedure
34+
callableStatement.execute();
35+
36+
// Checking if the import was successful
37+
//int status = callableStatement.getInt(2);
38+
/*if (status == 0) {
39+
System.out.println("SQL tuning task import successful.");
40+
41+
// Invoking DBMS_SQLTUNE package procedures for tuning the SQL statement
42+
// Example: DBMS_SQLTUNE.EXECUTE_TUNING_TASK(task_name => 'SQL_TUNING_TASK');
43+
// Example: DBMS_SQLTUNE.REPORT_TUNING_TASK(task_name => 'SQL_TUNING_TASK');
44+
// ...
45+
46+
// Don't forget to commit the changes
47+
connection.commit();
48+
} else {
49+
System.out.println("SQL tuning task import failed.");
50+
}*/
51+
} catch (SQLException e) {
52+
e.printStackTrace();
53+
} finally {
54+
// Closing the resources
55+
try {
56+
if (callableStatement != null) {
57+
callableStatement.close();
58+
}
59+
if (connection != null) {
60+
connection.close();
61+
}
62+
} catch (SQLException e) {
63+
e.printStackTrace();
64+
}
65+
}
66+
}
67+
}
68+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.dra;
5+
6+
import com.example.dra.entity.Edges;
7+
import com.example.dra.entity.Nodes;
8+
import lombok.Getter;
9+
import lombok.Setter;
10+
11+
import java.util.List;
12+
13+
@Setter
14+
@Getter
15+
public class ViewGraphResponse {
16+
List<Nodes> nodes;
17+
List<Edges> edges;
18+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.dra.bean;
5+
6+
import com.example.dra.entity.RefineNodes;
7+
import com.example.dra.entity.Nodes;
8+
import lombok.Getter;
9+
import lombok.Setter;
10+
11+
import java.util.List;
12+
13+
@Getter
14+
@Setter
15+
public class DatabaseDetails {
16+
17+
private String databaseName;
18+
private String hostname;
19+
private int port;
20+
private String username;
21+
private String password;
22+
private String url;
23+
private String sqlSetName;
24+
private String serviceName;
25+
private List<String> queries;
26+
private String graphData;
27+
private List<Nodes> refineNodesList;
28+
private List<RefineNodes> nodesList;
29+
30+
private String oldSQLSetName;
31+
private String oldSchemaOwner;
32+
33+
public DatabaseDetails() {
34+
35+
}
36+
37+
38+
@Override
39+
public String toString() {
40+
return "DatabaseDetails{" +
41+
"sqlSetName='" + sqlSetName + '\'' +
42+
", refineNodesList=" + refineNodesList +
43+
", nodeList=" + nodesList +
44+
'}';
45+
}
46+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.dra.communitydetection;
5+
6+
public class Constants {
7+
8+
public static final String SESSION_NAME_STR = "DataRefactoringAdvisorSession";
9+
10+
public static final String TENANT_STR = "tenant";
11+
public static final String DATABASE_STR = "database";
12+
public static final String CLOUD_DB_OCID = "cloud_db_ocid";
13+
public static final String DB_USERNAME_STR = "username";
14+
public static final String DB_PASSWORD_STR = "password";
15+
public static final String DB_ENDPOINT_STR = "endpoint";
16+
17+
public static final String GRAPH_NAME_STR = "graph_name";
18+
public static final String VERTEX_COLUMN_STR = "vertex_property_column";
19+
public static final String EDGE_SOURCE_COL_STR = "edge_property_source_column";
20+
public static final String EDGE_DESTINATION_COL_STR = "edge_property_destination_column";
21+
public static final String EDGE_WEIGHT_COL_STR = "edge_property_weight_column";
22+
23+
public static final String COMMUNITY_STR = "Community";
24+
}

0 commit comments

Comments
 (0)