Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
D
Database partitioning
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
ali.saeed
Database partitioning
Commits
cb93f30b
Commit
cb93f30b
authored
Apr 19, 2024
by
Ali Saeed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
users generator java project
parent
62cbf59e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
184 additions
and
0 deletions
+184
-0
.gitignore
UsersGenerator/.idea/.gitignore
+3
-0
compiler.xml
UsersGenerator/.idea/compiler.xml
+13
-0
encodings.xml
UsersGenerator/.idea/encodings.xml
+7
-0
jarRepositories.xml
UsersGenerator/.idea/jarRepositories.xml
+20
-0
misc.xml
UsersGenerator/.idea/misc.xml
+14
-0
pom.xml
UsersGenerator/pom.xml
+46
-0
UsersGenerator.java
UsersGenerator/src/main/java/UsersGenerator.java
+67
-0
log4j.properties
UsersGenerator/src/main/resources/log4j.properties
+7
-0
UsersGenerator.class
UsersGenerator/target/classes/UsersGenerator.class
+0
-0
log4j.properties
UsersGenerator/target/classes/log4j.properties
+7
-0
No files found.
UsersGenerator/.idea/.gitignore
0 → 100644
View file @
cb93f30b
# Default ignored files
/shelf/
/workspace.xml
UsersGenerator/.idea/compiler.xml
0 → 100644
View file @
cb93f30b
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"CompilerConfiguration"
>
<annotationProcessing>
<profile
name=
"Maven default annotation processors profile"
enabled=
"true"
>
<sourceOutputDir
name=
"target/generated-sources/annotations"
/>
<sourceTestOutputDir
name=
"target/generated-test-sources/test-annotations"
/>
<outputRelativeToContentRoot
value=
"true"
/>
<module
name=
"UsersGenerator"
/>
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
UsersGenerator/.idea/encodings.xml
0 → 100644
View file @
cb93f30b
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"Encoding"
>
<file
url=
"file://$PROJECT_DIR$/src/main/java"
charset=
"UTF-8"
/>
<file
url=
"file://$PROJECT_DIR$/src/main/resources"
charset=
"UTF-8"
/>
</component>
</project>
\ No newline at end of file
UsersGenerator/.idea/jarRepositories.xml
0 → 100644
View file @
cb93f30b
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"RemoteRepositoriesConfiguration"
>
<remote-repository>
<option
name=
"id"
value=
"central"
/>
<option
name=
"name"
value=
"Central Repository"
/>
<option
name=
"url"
value=
"https://repo.maven.apache.org/maven2"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"central"
/>
<option
name=
"name"
value=
"Maven Central repository"
/>
<option
name=
"url"
value=
"https://repo1.maven.org/maven2"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"jboss.community"
/>
<option
name=
"name"
value=
"JBoss Community repository"
/>
<option
name=
"url"
value=
"https://repository.jboss.org/nexus/content/repositories/public/"
/>
</remote-repository>
</component>
</project>
\ No newline at end of file
UsersGenerator/.idea/misc.xml
0 → 100644
View file @
cb93f30b
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ExternalStorageConfigurationManager"
enabled=
"true"
/>
<component
name=
"MavenProjectsManager"
>
<option
name=
"originalFiles"
>
<list>
<option
value=
"$PROJECT_DIR$/pom.xml"
/>
</list>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_17"
default=
"true"
project-jdk-name=
"17 (2)"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/out"
/>
</component>
</project>
\ No newline at end of file
UsersGenerator/pom.xml
0 → 100644
View file @
cb93f30b
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
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>
org.example
</groupId>
<artifactId>
UsersGenerator
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<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>
<properties>
<maven.compiler.source>
17
</maven.compiler.source>
<maven.compiler.target>
17
</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
</project>
\ No newline at end of file
UsersGenerator/src/main/java/UsersGenerator.java
0 → 100644
View file @
cb93f30b
import
com.mongodb.client.*
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.bson.Document
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
public
class
UsersGenerator
{
private
static
final
String
MONGOS_URL
=
"mongodb://192.168.181.136:27046"
;
private
static
final
String
DB_NAME
=
"MoviesDB"
;
private
static
final
String
COLLECTION_NAME
=
"users"
;
private
static
final
Random
random
=
new
Random
();
public
static
void
main
(
String
[]
args
)
{
MongoDatabase
MoviesDB
=
connectToMongos
(
DB_NAME
);
generateUsers
(
10000
,
MoviesDB
,
COLLECTION_NAME
);
}
private
static
MongoDatabase
connectToMongos
(
String
dbName
)
{
MongoClient
mongoClient
=
MongoClients
.
create
(
MONGOS_URL
);
return
mongoClient
.
getDatabase
(
dbName
);
}
private
static
void
generateUsers
(
int
numberOfUsers
,
MongoDatabase
database
,
String
collectionName
)
{
MongoCollection
<
Document
>
collection
=
database
.
getCollection
(
collectionName
);
List
<
Document
>
documents
=
new
ArrayList
<>();
System
.
out
.
println
(
"Generating "
+
numberOfUsers
+
" user"
);
for
(
int
userIndex
=
0
;
userIndex
<
numberOfUsers
;
userIndex
++)
{
Document
document
=
new
Document
();
document
.
append
(
"user_name"
,
generateUserName
())
.
append
(
"watched_movies"
,
generateWatchedMovies
())
.
append
(
"subscription_month"
,
generateSubscriptionMonth
());
documents
.
add
(
document
);
}
collection
.
insertMany
(
documents
);
System
.
out
.
println
(
"Finished generating users"
);
}
private
static
String
generateUserName
()
{
return
RandomStringUtils
.
randomAlphabetic
(
10
);
}
private
static
List
<
String
>
generateWatchedMovies
()
{
int
numberOfMovies
=
random
.
nextInt
(
4
)
+
1
;
List
<
String
>
movies
=
new
ArrayList
<>(
numberOfMovies
);
for
(
int
i
=
0
;
i
<
numberOfMovies
;
i
++)
{
movies
.
add
(
"Movie "
+
(
i
+
1
));
}
return
movies
;
}
private
static
String
generateSubscriptionMonth
()
{
int
month
=
random
.
nextInt
(
12
)
+
1
;
int
year
=
random
.
nextInt
(
10
)
+
2015
;
return
String
.
format
(
"%02d-%04d"
,
month
,
year
);
}
}
\ No newline at end of file
UsersGenerator/src/main/resources/log4j.properties
0 → 100644
View file @
cb93f30b
# 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
UsersGenerator/target/classes/UsersGenerator.class
0 → 100644
View file @
cb93f30b
File added
UsersGenerator/target/classes/log4j.properties
0 → 100644
View file @
cb93f30b
# 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