Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
G
generator_mongodb
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
areej.mohammad
generator_mongodb
Commits
ff88aefd
Commit
ff88aefd
authored
Apr 20, 2026
by
AreejMh57
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
6cb5b187
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
38 additions
and
2 deletions
+38
-2
misc.xml
.idea/misc.xml
+1
-1
MoviesGenerator.java
src/main/java/MoviesGenerator.java
+25
-1
MoviesGenerator.class
target/classes/MoviesGenerator.class
+0
-0
log4j.properties
target/classes/log4j.properties
+7
-0
insert-many-movies-1.0-SNAPSHOT-jar-with-dependencies.jar
...insert-many-movies-1.0-SNAPSHOT-jar-with-dependencies.jar
+0
-0
insert-many-movies-1.0-SNAPSHOT.jar
target/insert-many-movies-1.0-SNAPSHOT.jar
+0
-0
pom.properties
target/maven-archiver/pom.properties
+3
-0
createdFiles.lst
...-compiler-plugin/compile/default-compile/createdFiles.lst
+1
-0
inputFiles.lst
...en-compiler-plugin/compile/default-compile/inputFiles.lst
+1
-0
No files found.
.idea/misc.xml
View file @
ff88aefd
...
...
@@ -8,7 +8,7 @@
</list>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1
1"
project-jdk-name=
"11
"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1
7"
default=
"true"
project-jdk-name=
"17
"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/out"
/>
</component>
</project>
\ No newline at end of file
src/main/java/MoviesGenerator.java
View file @
ff88aefd
...
...
@@ -12,7 +12,7 @@ import java.util.Random;
public
class
MoviesGenerator
{
//router address
private
static
final
String
MONGO_DB_URL
=
"mongodb://1
72.29.3.101
:27033/"
;
private
static
final
String
MONGO_DB_URL
=
"mongodb://1
92.168.144.132
:27033/"
;
private
static
final
String
DB_NAME
=
"videodb"
;
private
static
final
String
COLLECTION_NAME
=
"movies"
;
...
...
@@ -21,6 +21,7 @@ public class MoviesGenerator {
public
static
void
main
(
String
[]
args
)
{
MongoDatabase
onlineSchoolDb
=
connectToMongoDB
(
MONGO_DB_URL
,
DB_NAME
);
generateMovies
(
10000
,
onlineSchoolDb
,
COLLECTION_NAME
);
generateUsers
(
10000
,
onlineSchoolDb
);
}
private
static
MongoDatabase
connectToMongoDB
(
String
url
,
String
dbName
)
{
...
...
@@ -93,4 +94,27 @@ public class MoviesGenerator {
return
name
.
toString
();
}
private
static
void
generateUsers
(
int
numberOfUsers
,
MongoDatabase
database
)
{
MongoCollection
<
Document
>
collection
=
database
.
getCollection
(
"users"
);
List
<
Document
>
userDocs
=
new
ArrayList
<>();
String
[]
sampleMovies
=
{
"Inside out"
,
"Aladdin"
,
"The Lion King"
,
"Matrix"
,
"Inception"
};
for
(
int
i
=
0
;
i
<
numberOfUsers
;
i
++)
{
Document
user
=
new
Document
()
.
append
(
"user_name"
,
"User_"
+
RandomStringUtils
.
randomAlphabetic
(
5
))
.
append
(
"watched_movies"
,
List
.
of
(
sampleMovies
[
random
.
nextInt
(
sampleMovies
.
length
)],
sampleMovies
[
random
.
nextInt
(
sampleMovies
.
length
)]
))
.
append
(
"subscription_month"
,
random
.
nextInt
(
12
)
+
1
);
userDocs
.
add
(
user
);
if
(
i
%
1000
==
0
)
{
collection
.
insertMany
(
userDocs
);
userDocs
.
clear
();
}
}
System
.
out
.
println
(
"Finished generating users with Hashed Sharding."
);
}
}
target/classes/MoviesGenerator.class
0 → 100644
View file @
ff88aefd
File added
target/classes/log4j.properties
0 → 100644
View file @
ff88aefd
# 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
target/insert-many-movies-1.0-SNAPSHOT-jar-with-dependencies.jar
0 → 100644
View file @
ff88aefd
File added
target/insert-many-movies-1.0-SNAPSHOT.jar
0 → 100644
View file @
ff88aefd
File added
target/maven-archiver/pom.properties
0 → 100644
View file @
ff88aefd
artifactId
=
insert-many-movies
groupId
=
distributed.systems
version
=
1.0-SNAPSHOT
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
0 → 100644
View file @
ff88aefd
MoviesGenerator.class
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
0 → 100644
View file @
ff88aefd
C:\Users\J.N\IdeaProjects\movies-generator-mongodb\src\main\java\MoviesGenerator.java
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