Handles indexing and searching of the database in it's own api.
-
-
Get mySQL:
docker pull mysql -
Create mySQL container:
docker run \ --name mysql-instance \ -e MYSQL_DATABASE=<mysql_db> \ -e MYSQL_USER=<username> \ -e MYSQL_PASSWORD=<password> \ -e MYSQL_ROOT_PASSWORD=<root_password> \ --publish 3306:3306 \ -d mysql -
-
-
Get postgres:
docker pull postgres -
Create postgres container:
docker run \ --name postgres-instance \ -e POSTGRES_PASSWORD=<password> \ --publish 5432:5432 \ -d postgres -
-
-
Start:
docker start postgres-instance -
Stop:
docker stop postgres-instance
If you cannot access postgres on
localhost:5432,Run
docker inspect postgres-instance | grep IPAddressordocker inspect postgres-instanceto find:"IPAddress": "xxx.xx.x.x",
To get the direct hostname
-
-
-
Get PGAdmin
docker pull dpage/pgadmin4 -
Create PGAdmin container:
docker run \ --name pgadmin-instance \ -p 5050:80 \ -e "PGADMIN_DEFAULT_EMAIL=name@gmail.com" \ -e "PGADMIN_DEFAULT_PASSWORD=admin" \ -d dpage/pgadmin4-
Start:
docker start pgadmin-instance -
Stop:
docker stop pgadmin-instance
If you cannot access it via
localhost:80/loginorlocalhost:5050/login,NOTE: Sometimes the browser matters, so if either of the above don't work try swapping browsers.
Run
docker inspect pgadmin-instance | grep IPAddressordocker inspect pgadmin-instanceto find:"IPAddress": "xxx.xx.x.x",
And try using this instead.
Once you get to the login page, use the email and password from the
docker runcommand from earlierThen add a new server, set any name, for host you can try
localhostor the host from thedocker inspectunder the postgres section.Username should be
postgresby default, password is whatever you set earlier. -
-
Download Glassfish (Full Profile)
-
Extract and cd into folder
-
For Linux Run
./glassfish/bin/asadmin start-domain domain1to start the server -
For Windows Run
./glassfish/bin/asadmin.bat start-domain domain1to start the server -
Once running you can visit
http://localhost:4848/for admin console
-
-
(Windows ONLY) If you're running into an issue where starting the domain1 server times out. Check if anything is running on ports
8080or4848 -
Do
netstat -ano | findstr :<PORT>to see if anything is running on that port. If something shows up, take the PID number (last column) and use that to kill the process -
Do
taskkill /PID <PID> /Fto kill process. (example:netstat -ano | findstr :8080-> Task running with PID: 1234 ->taskkill /PID 1234 /F) -
Now try
start-domain domain1again, should work.
-
-
- Right click the project
> Export > War File
-
Right click the project in file explorer
> Clean and Buildthen check the console for where the .war file was built. -
Choose output and hit finish
-
cd into the glassfish folder and run
./glassfish/bin/asadmin deploy <path-to-war-file> -
Once deployed visit
http://localhost:8080/<WAR FILE TITLE>/api -
Example, my .WAR compiled as
searchIndex-1.0-SNAPSHOT.wartherefore I access the api via:http://localhost:8080/searchIndex-1.0-SNAPSHOT/api
- Right click the project
-
- Run
asadmin list-applications --type webto view all Web Deployments of Glassfish currently running.
- Run
-
- Run
undeploy <Web Instance>, Example:undeploy searchIndex-1.0-SNAPSHOT
- Run
-
- Run
deploy <path-to-war-file>to deploy new version of API
- Run
The Example Below is from the Windows asadmin.bat CLI tool
asadmin> list-applications --type web
searchIndex-1.0-SNAPSHOT <web>
Command list-applications executed successfully.
asadmin> undeploy searchIndex-1.0-SNAPSHOT
Command undeploy executed successfully.
asadmin> deploy C:/Users/jason/.m2/repository/org/ezcampus/searchIndex/1.0-SNAPSHOT/searchIndex-1.0-SNAPSHOT.war
Application deployed with name searchIndex-1.0-SNAPSHOT.
Command deploy executed successfully.Docker CLI enter container & enter MySQL:
docker exec -it mysql-instance bash
mysql -u max -p
**ENTER PASS**
Clearing all SearchIndex related tables in MySQL:
use search_db;
SET FOREIGN_KEY_CHECKS = 0;
Truncate tbl_classtype;
Truncate tbl_course;
Truncate tbl_course_data;
Truncate tbl_course_faculty;
Truncate tbl_faculty;
Truncate tbl_meeting;
Truncate tbl_scrape_history;
Truncate tbl_term;
Truncate tbl_word;
Truncate tbl_word_course_data;
SET FOREIGN_KEY_CHECKS = 1;This will be used for running the glassfish server/api
-
Open the root in IntelliJ
-
Allow it to create indexes/paths if prompted
-
Create run config:
Run (at the top) > Edit Configurations > + (in top left) > Glassfish Server > Local
Under Run config settings:
-
Application Server:
Glassfish 7.x.x -
URL:
http://localhost:8080/searchIndex-1.0-SNAPSHOT/api/ -
JRE:
OpenJDK-17 Temurinor similar (17 or higher should be find) -
Server Domain:
domain1 -
Username:
admin -
Password: (there is no password)
-
Under
Deploymentat the top+ > Artifact > War artifact
Apply changes and close
This CMD script needs to be ran as Administrator, it essentially kills whatever task is running on port tcp:8080
Glassfish7 uses this port, and it throws cryptic errors when something is block it