Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
M
MongoShard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
diaa.hanna
MongoShard
Commits
c9e0ca66
Commit
c9e0ca66
authored
Apr 21, 2026
by
drnull03
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed readme and submodule issue
parent
19899ab8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
200 additions
and
9 deletions
+200
-9
README.md
README.md
+23
-8
movies-generator-mongodb
movies-generator-mongodb
+0
-1
pom.xml
movies-generator-mongodb/pom.xml
+74
-0
MoviesGenerator.java
movies-generator-mongodb/src/main/java/MoviesGenerator.java
+96
-0
log4j.properties
movies-generator-mongodb/src/main/resources/log4j.properties
+7
-0
No files found.
README.md
View file @
c9e0ca66
#
## Project Structure
#
Project Structure
This repository is organized as follows:
commands.sh(commands used to setup the database sharding and replication configserver and router)
-
**commands.sh**
gitlab.txt (the link for the repo)
Contains the commands used to set up the MongoDB sharding, replication, config server, and router.
movies-generator-mongodb(old project taken from the provided github repo don't open this folder)
Report (folder containing report for the homework)
-
**gitlab.txt**
data (folder that is ignored with .gitignore contains that actual db data and shards)
Includes the link to the GitLab repository.
movie.shard-app (spring boot command line app written for this homework it stress test with 10000 records and 5000 users record)
README.md (this file)
-
**movies-generator-mongodb**
Old project taken from the provided GitHub repository.
*(Do not open or modify this folder.)*
-
**Report/**
Folder containing the homework report.
-
**data/**
Ignored via
`.gitignore`
. Contains the actual database data and shard files.
-
**movie.shard-app**
A Spring Boot command-line application written for this homework.
Used to stress test the system with multiple operations.
-
**README.md**
This file.
movies-generator-mongodb
@
6cb5b187
Subproject commit 6cb5b18792db4ca0e9a5722dd36273d88d04edd6
movies-generator-mongodb/pom.xml
0 → 100644
View file @
c9e0ca66
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
distributed.systems
</groupId>
<artifactId>
insert-many-movies
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.8.0
</version>
<configuration>
<release>
11
</release>
</configuration>
</plugin>
<plugin>
<artifactId>
maven-assembly-plugin
</artifactId>
<executions>
<execution>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>
MoviesGenerator
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.9
</version>
</dependency>
<dependency>
<groupId>
org.mongodb
</groupId>
<artifactId>
mongodb-driver-sync
</artifactId>
<version>
5.0.1
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
<version>
1.7.6
</version>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<version>
1.2.17
</version>
<scope>
runtime
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
movies-generator-mongodb/src/main/java/MoviesGenerator.java
0 → 100644
View file @
c9e0ca66
import
com.mongodb.client.MongoClient
;
import
com.mongodb.client.MongoClients
;
import
com.mongodb.client.MongoCollection
;
import
com.mongodb.client.MongoDatabase
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.bson.Document
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
public
class
MoviesGenerator
{
//router address
private
static
final
String
MONGO_DB_URL
=
"mongodb://172.29.3.101:27033/"
;
private
static
final
String
DB_NAME
=
"videodb"
;
private
static
final
String
COLLECTION_NAME
=
"movies"
;
private
static
final
Random
random
=
new
Random
();
public
static
void
main
(
String
[]
args
)
{
MongoDatabase
onlineSchoolDb
=
connectToMongoDB
(
MONGO_DB_URL
,
DB_NAME
);
generateMovies
(
10000
,
onlineSchoolDb
,
COLLECTION_NAME
);
}
private
static
MongoDatabase
connectToMongoDB
(
String
url
,
String
dbName
)
{
MongoClient
mongoClient
=
MongoClients
.
create
(
MONGO_DB_URL
);
return
mongoClient
.
getDatabase
(
dbName
);
}
private
static
void
generateMovies
(
int
numberOfMovies
,
MongoDatabase
database
,
String
collectionName
)
{
MongoCollection
<
Document
>
collection
=
database
.
getCollection
(
collectionName
);
List
<
Document
>
documents
=
new
ArrayList
<>();
System
.
out
.
println
(
"Generating "
+
numberOfMovies
+
" movies"
);
for
(
int
movieIndex
=
0
;
movieIndex
<
numberOfMovies
;
movieIndex
++)
{
Document
document
=
new
Document
();
document
.
append
(
"title"
,
generateName
())
.
append
(
"directors"
,
generateDirectorNames
())
.
append
(
"rating"
,
generateRating
())
.
append
(
"cast"
,
generateCast
());
documents
.
add
(
document
);
}
collection
.
insertMany
(
documents
);
System
.
out
.
println
(
"Finished generating movies"
);
}
private
static
List
<
String
>
generateDirectorNames
()
{
int
numberOfDirectors
=
random
.
nextInt
(
3
)
+
1
;
List
<
String
>
directors
=
new
ArrayList
<>(
numberOfDirectors
);
for
(
int
i
=
0
;
i
<
numberOfDirectors
;
i
++)
{
String
firstName
=
generateName
();
String
lastName
=
generateName
();
directors
.
add
(
firstName
+
" "
+
lastName
);
}
return
directors
;
}
private
static
int
generateYear
()
{
return
random
.
nextInt
(
119
)
+
1900
;
}
private
static
float
generateRating
()
{
return
random
.
nextFloat
()
*
10.0f
;
}
private
static
List
<
String
>
generateCast
()
{
int
numberOfActors
=
random
.
nextInt
(
20
)
+
10
;
List
<
String
>
actors
=
new
ArrayList
<>(
numberOfActors
);
for
(
int
i
=
0
;
i
<
numberOfActors
;
i
++)
{
String
firstName
=
generateName
();
String
lastName
=
generateName
();
actors
.
add
(
firstName
+
" "
+
lastName
);
}
return
actors
;
}
private
static
String
generateName
()
{
StringBuilder
name
=
new
StringBuilder
();
name
.
append
(
RandomStringUtils
.
randomAlphabetic
(
1
).
toUpperCase
());
name
.
append
(
RandomStringUtils
.
randomAlphabetic
(
5
,
10
).
toLowerCase
());
return
name
.
toString
();
}
}
movies-generator-mongodb/src/main/resources/log4j.properties
0 → 100644
View file @
c9e0ca66
# Root logger option
log4j.rootLogger
=
ERROR, stdout
# Direct log messages to stdout
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern
=
%d{HH:mm:ss} %-5p %c{1}:%L - %m%n
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment