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

NoSQL improvement: Helidon uses now Jakarta Nosql / better Nosql code with QueryIterable for Node, Dotnet #84

Merged
merged 13 commits into from
Mar 12, 2024
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
5 changes: 4 additions & 1 deletion basis/bin/auto_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ "$TF_VAR_instance_shape" == "VM.Standard.A1.Flex" ]; then
if [ "$TF_VAR_deploy_type" == "kubernetes" ] || [ "$TF_VAR_deploy_type" == "container_instance" ] || [ "$TF_VAR_deploy_type" == "function" ]; then
MISMATCH_PLATFORM="ERROR: ARM (Ampere) build using Containers (Kubernetes / Cointainer Instance / Function) needs to run on ARM processor"
DESIRED_PLATFORM="ARM (aarch64)"
fi
fi
fi
elif [ `arch` != "x86_64" ]; then
if [ "$TF_VAR_deploy_type" == "kubernetes" ] || [ "$TF_VAR_deploy_type" == "container_instance" ] || [ "$TF_VAR_deploy_type" == "function" ]; then
Expand Down Expand Up @@ -61,6 +61,9 @@ if [ "$1" == "-no-auto" ]; then
return
fi

# Change the prompt
export PS1="[\e[0;3m\${TF_VAR_prefix}\e(B\e[m \u@\h \W]$ "

# Silent mode (default is not silent)
if [ "$1" == "-silent" ]; then
SILENT_MODE=true
Expand Down
9 changes: 8 additions & 1 deletion basis/bin/shared_bash_function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ get_ui_url() {
elif [ "$TF_VAR_deploy_type" == "kubernetes" ]; then
export TF_VAR_ingress_ip=`kubectl get service -n ingress-nginx ingress-nginx-controller -o jsonpath="{.status.loadBalancer.ingress[0].ip}"`
export UI_URL=http://${TF_VAR_ingress_ip}/${TF_VAR_prefix}
if [ "$TF_VAR_tls" != "" ] && [ "$TF_VAR_certificate_ocid" != "" ]; then
if [ "$TF_VAR_tls" != "" ] && [ "$TF_VAR_dns_name" != "" ]; then
export UI_HTTP=$UI_URL
export UI_URL=https://${TF_VAR_dns_name}/${TF_VAR_prefix}
fi
Expand Down Expand Up @@ -510,6 +510,13 @@ certificate_dir_before_terraform() {
echo "ERROR: compute: certificate_dir_before_terraform: missing variables TF_VAR_certificate_dir"
exit 1
fi
elif [ "$TF_VAR_deploy_type" == "kubernetes" ]; then
if [ "$TF_VAR_tls" == "new_http_01" ]; then
echo "New Certificate will be created after the deployment."
else
echo "ERROR: kubernetes: certificate_dir_before_terraform: missing variables TF_VAR_certificate_dir"
exit 1
fi
elif [ "$TF_VAR_certificate_ocid" == "" ] && [ "$TF_VAR_certificate_dir" != "" ] ; then
certificate_create
elif [ "$TF_VAR_certificate_ocid" != "" ]; then
Expand Down
10 changes: 5 additions & 5 deletions basis/bin/shared_infra_as_code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ resource_manager_create_or_update() {
VAR_FILE_PATH=$TARGET_DIR/resource_manager_variables.json
if [ -f $TARGET_DIR/resource_manager_stackid ]; then
echo "Stack exists already ( file target/resource_manager_stackid found )"
BACKUP_POSTFIX=`date '+%Y%m%d-%H%M%S'`
mv $ZIP_FILE_PATH $ZIP_FILE_PATH.$BACKUP_POSTFIX
mv $VAR_FILE_PATH $VAR_FILE_PATH.$BACKUP_POSTFIX
DATE_POSTFIX=`date '+%Y%m%d-%H%M%S'`
mv $ZIP_FILE_PATH $ZIP_FILE_PATH.$DATE_POSTFIX
mv $VAR_FILE_PATH $VAR_FILE_PATH.$DATE_POSTFIX
fi

if [ -f $ZIP_FILE_PATH ]; then
Expand All @@ -77,9 +77,9 @@ resource_manager_create_or_update() {
cat $TARGET_DIR/tf_var.sh | sed "s/export TF_VAR_/\"/g" | sed "s/=\"/\": \"/g" | sed ':a;N;$!ba;s/\"\n/\", /g' | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/$/}/'>> $VAR_FILE_PATH

if [ -f $TARGET_DIR/resource_manager_stackid ]; then
if cmp -s $ZIP_FILE_PATH $ZIP_FILE_PATH.$BACKUP_POSTFIX; then
if cmp -s $ZIP_FILE_PATH $ZIP_FILE_PATH.$DATE_POSTFIX; then
rs_echo "Zip files are identical"
if cmp -s $VAR_FILE_PATH $VAR_FILE_PATH.$BACKUP_POSTFIX; then
if cmp -s $VAR_FILE_PATH $VAR_FILE_PATH.$DATE_POSTFIX; then
rs_echo "Var files are identical"
exit
else
Expand Down
57 changes: 36 additions & 21 deletions basis/starter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,56 @@ export ARG2=$2
export ARG3=$3

if [ -z $ARG1 ] || [ "$ARG1" == "help" ]; then
echo "Help:"
echo "--- HELP -------------------------------------------------------------------------------------"
echo "https://www.ocistarter.com/"
echo "https://www.ocistarter.com/help (tutorial + how to customize)"
echo
echo "--- BUILD -------------------------------------------------------------------------"
echo "./starter.sh build - Build all"
echo "./starter.sh build app - Build the application"
echo "./starter.sh build ui - Build the user interface"
echo "--- BUILD ------------------------------------------------------------------------------------"
echo "./starter.sh build - Build and deploy"
echo "./starter.sh build app - Build the application (APP)"
echo "./starter.sh build ui - Build the user interface (UI)"
echo
echo "--- DESTROY -----------------------------------------------------------------------"
echo "--- DESTROY ----------------------------------------------------------------------------------"
echo "./starter.sh destroy - Destroy all"
echo
echo "--- SSH ---------------------------------------------------------------------------"
echo "./starter.sh ssh compute - SSH to compute (Compute mode)"
echo "--- SSH --------------------------------------------------------------------------------------"
echo "./starter.sh ssh compute - SSH to compute (Deployment: Compute)"
echo "./starter.sh ssh bastion - SSH to bastion"
echo "./starter.sh ssh db_node - SSH to DB_NODE (OCI Oracle Base DB)"
echo "./starter.sh ssh db_node - SSH to DB_NODE (Database: Oracle DB)"
echo
echo "--- TERRAFORM (or RESOURCE MANAGER ) ----------------------------------------------"
echo "--- TERRAFORM (or RESOURCE MANAGER ) ---------------------------------------------------------"
echo "./starter.sh terraform plan - Plan"
echo "./starter.sh terraform apply - Apply"
echo "./starter.sh terraform destroy - Destroy"
echo
echo "--- GENERATE ----------------------------------------------------------------------"
echo "--- GENERATE ---------------------------------------------------------------------------------"
echo "./starter.sh generate auth_token - Create OCI Auth Token (ex: docker login)"
echo
echo "--- DEPLOY ------------------------------------------------------------------------"
echo "--- DEPLOY -----------------------------------------------------------------------------------"
echo "./starter.sh deploy bastion - Deploy the bastion (+create DB tables)"
echo "./starter.sh deploy compute - Deploy APP and UI on Compute (Compute mode)"
echo "./starter.sh deploy oke - Deploy APP and UI on OKE (OKE mode)"
echo "./starter.sh deploy compute - Deploy APP and UI on Compute (Deployment: Compute)"
echo "./starter.sh deploy oke - Deploy APP and UI on OKE (Deployment: Kubernetes)"
echo
echo "--- KUBECTL -----------------------------------------------------------------------"
echo ". ./env.sh - Set kubeconfig to connect to Kubernetes"
echo "--- KUBECTL ----------------------------------------------------------------------------------"
echo "./starter.sh env - Set kubeconfig to connect to Kubernetes"
echo "kubectl get pods - Example of a command to check the PODs"
echo
exit
fi

if [ "$ARG1" == "build" ]; then
# Show the log and save it in target/build.log
bin/build_all.sh ${@:2} 2>&1 | tee $TARGET_DIR/build.log
if [ "$ARG2" == "" ]; then
# Show the log and save it in target/build.log
bin/build_all.sh ${@:2} 2>&1 | tee $TARGET_DIR/build.log
elif [ "$ARG2" == "app" ]; then
src/app/build_app.sh ${@:2}
elif [ "$ARG2" == "ui" ]; then
src/ui/build_ui.sh ${@:2}
else
echo "Unknow command: $ARG1 $ARG2"
fi


elif [ "$ARG1" == "destroy" ]; then
bin/destroy_all.sh ${@:2} 2>&1 | tee $TARGET_DIR/destroy.log
elif [ "$ARG1" == "ssh" ]; then
Expand All @@ -60,11 +73,11 @@ elif [ "$ARG1" == "ssh" ]; then
fi
elif [ "$ARG1" == "terraform" ]; then
if [ "$ARG2" == "plan" ]; then
src/terraform/plan.sh $ARG3
src/terraform/plan.sh ${@:2}
elif [ "$ARG2" == "apply" ]; then
src/terraform/apply.sh $ARG3
src/terraform/apply.sh ${@:2}
elif [ "$ARG2" == "destroy" ]; then
src/terraform/destroy.sh $ARG3
src/terraform/destroy.sh ${@:2}
else
echo "Unknow command: $ARG1 $ARG2"
fi
Expand All @@ -85,6 +98,8 @@ elif [ "$ARG1" == "deploy" ]; then
echo "Unknow command: $ARG1 $ARG2"
exit 1
fi
elif [ "$ARG1" == "env" ]; then
bash --rcfile ./env.sh
else
echo "Unknow command: $ARG1"
exit 1
Expand Down
3 changes: 2 additions & 1 deletion option/oke/oke_destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ helm uninstall ingress-nginx --namespace ingress-nginx
# kubectl delete -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.4.0/deploy/static/provider/cloud/deploy.yaml

# Rename kubeconfig. Avoid to reuse if a new OKE is created for the same directory.
mv kubeconfig_starter kubeconfig_starter.destroyed
DATE_POSTFIX=`date '+%Y%m%d-%H%M%S'`
mv $KUBECONFIG $KUBECONFIG.${DATE_POSTFIX}
4 changes: 4 additions & 0 deletions option/src/app/dotnet/src/Controllers/DeptController.j2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ public DeptController(ILogger<DeptController> logger)
}

[Route("dept")]
{%- if db_family == "nosql" %}
public async Task<IEnumerable<Dept>> Get()
{%- else %}
public IEnumerable<Dept> Get()
{%- endif %}
{
{{ m.dept() }}
return a.ToArray();
Expand Down
19 changes: 9 additions & 10 deletions option/src/app/java_helidon/microprofile-config.properties.j2.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ server.host=0.0.0.0
# Change the following to true to enable the optional MicroProfile Metrics REST.request metrics
metrics.rest-request.enabled=false

# Application properties. This is the default greeting
app.greeting=Hello

# Datasource properties
{%- if db_family != "none" %}
{%- if db_family == "oracle" %}
Expand All @@ -17,15 +14,11 @@ javax.sql.DataSource.ds1.dataSourceClassName=com.mysql.cj.jdbc.MysqlDataSource
{%- elif db_family == "psql" %}
javax.sql.DataSource.ds1.dataSourceClassName=org.postgresql.ds.PGSimpleDataSource
{%- endif %}
javax.sql.DataSource.ds1.dataSource.url=##JDBC_URL##
javax.sql.DataSource.ds1.dataSource.user=##DB_USER##
javax.sql.DataSource.ds1.dataSource.password=##DB_PASSWORD##
{%- endif %}

{%- if db_family == "nosql" %}
# Oracle NoSQL Connection
jnosql.keyvalue.database=dept
jnosql.document.database=dept
jnosql.keyvalue.database=deptjee
jnosql.document.database=deptjee
jnosql.oracle.nosql.table.read.limit=10
jnosql.oracle.nosql.table.write.limit=10
jnosql.oracle.nosql.table.storage.gb=1
Expand All @@ -35,5 +28,11 @@ jnosql.oracle.nosql.compartment=${TF_VAR_compartment_ocid}
jnosql.oracle.nosql.deployment=CLOUD_INSTANCE_PRINCIPAL
{%- else %}
jnosql.oracle.nosql.deployment=CLOUD_RESOURCE_PRINCIPAL
{%- endif %}
{%- endif %}
{%- else %}
javax.sql.DataSource.ds1.dataSource.url=##JDBC_URL##
javax.sql.DataSource.ds1.dataSource.user=##DB_USER##
javax.sql.DataSource.ds1.dataSource.password=##DB_PASSWORD##
{%- endif %}
{%- endif %}

2 changes: 1 addition & 1 deletion option/src/app/java_helidon/pom.j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.helidon.applications</groupId>
<artifactId>helidon-mp</artifactId>
<version>3.1.0</version>
<version>3.2.6</version>
<relativePath/>
</parent>
<groupId>me.opc-helidon</groupId>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@

@Entity
@JsonbVisibility(FieldAccessStrategy.class)
public class Dept {
@Id
private int deptno;
@Column
private String dname;
@Column
private String loc;
public record Dept (@Id int deptno,
@Column String dname,
@Column String loc) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% import "java.j2_macro" as m with context %}
package me.opc.mp.database;

import jakarta.persistence.*;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.inject.*;
import jakarta.annotation.*;
{{ m.import() }}

/**
* Dept Table
*/
@Path("/")
public class DeptResource {
@Inject
private DeptRepository repository;

@PostConstruct
private void init() {
try {
System.out.println("Insert row " + repository.save(new Dept(10, "ACCOUNTING", "BRUSSELS")));
System.out.println("Insert row " + repository.save(new Dept(20, "RESEARCH", "JAKARTA NOSQL")));
System.out.println("Insert row " + repository.save(new Dept(30, "SALES", "ROME")));
System.out.println("Insert row " + repository.save(new Dept(40, "OPERATIONS", "MADRID")));
} catch (Exception e ) {
System.err.println("Init Exception:" + e.getMessage());
e.printStackTrace();
}
}

@GET
@Path("dept")
@Produces(MediaType.APPLICATION_JSON)
public List<Dept> getDept() throws Exception {
return repository.findAll().toList();
}

@GET
@Path("info")
@Produces(MediaType.TEXT_PLAIN)
public String getInfo() {
return "Java - Helidon - {{ dbName }}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void run() {
}

@Autowired
public RacController(DbProperties aProperties) throws SQLException {
public RacController() throws SQLException {
resetConnectionPool("jtac");
}

Expand Down
Loading