Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
M
MongoDB-Hash-Sharding
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
mohammad.salama
MongoDB-Hash-Sharding
Commits
0d3be7b4
Commit
0d3be7b4
authored
Apr 20, 2024
by
mohammad.salama
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All Done
parent
5ef39394
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
0 additions
and
240 deletions
+0
-240
compiler.xml
MongoDB-Reader/.idea/compiler.xml
+0
-13
encodings.xml
MongoDB-Reader/.idea/encodings.xml
+0
-7
jarRepositories.xml
MongoDB-Reader/.idea/jarRepositories.xml
+0
-20
misc.xml
MongoDB-Reader/.idea/misc.xml
+0
-14
workspace.xml
MongoDB-Reader/.idea/workspace.xml
+0
-44
pom.xml
MongoDB-Reader/pom.xml
+0
-38
Main.java
MongoDB-Reader/src/main/java/org/example/Main.java
+0
-90
log4j.properties
MongoDB-Reader/src/main/resources/log4j.properties
+0
-7
log4j.properties
MongoDB-Reader/target/classes/log4j.properties
+0
-7
Main.class
MongoDB-Reader/target/classes/org/example/Main.class
+0
-0
Report.docx
Report.docx
+0
-0
Report.pdf
Report.pdf
+0
-0
No files found.
MongoDB-Reader/.idea/compiler.xml
deleted
100644 → 0
View file @
5ef39394
<?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=
"MongoDB-Reader"
/>
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
MongoDB-Reader/.idea/encodings.xml
deleted
100644 → 0
View file @
5ef39394
<?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
MongoDB-Reader/.idea/jarRepositories.xml
deleted
100644 → 0
View file @
5ef39394
<?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
MongoDB-Reader/.idea/misc.xml
deleted
100644 → 0
View file @
5ef39394
<?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
MongoDB-Reader/.idea/workspace.xml
deleted
100644 → 0
View file @
5ef39394
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"AutoImportSettings"
>
<option
name=
"autoReloadType"
value=
"SELECTIVE"
/>
</component>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"9ca737e0-d8bf-4a68-bfb8-89308a7b8ac5"
name=
"Changes"
comment=
""
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
<option
name=
"LAST_RESOLUTION"
value=
"IGNORE"
/>
</component>
<component
name=
"MarkdownSettingsMigration"
>
<option
name=
"stateVersion"
value=
"1"
/>
</component>
<component
name=
"ProjectId"
id=
"2fBLnNuNH4twkdBUWpeq0CmKFn3"
/>
<component
name=
"ProjectViewState"
>
<option
name=
"hideEmptyMiddlePackages"
value=
"true"
/>
<option
name=
"showLibraryContents"
value=
"true"
/>
</component>
<component
name=
"PropertiesComponent"
>
<![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"last_opened_file_path": "D:/HIAST/FIY/SS/Advanced Distributed Systems/Lab/5/MongoDB-Reader/src/main/resources"
}
}]]>
</component>
<component
name=
"RecentsManager"
>
<key
name=
"CopyFile.RECENT_KEYS"
>
<recent
name=
"D:\HIAST\FIY\SS\Advanced Distributed Systems\Lab\5\MongoDB-Reader\src\main\resources"
/>
</key>
</component>
<component
name=
"SpellCheckerSettings"
RuntimeDictionaries=
"0"
Folders=
"0"
CustomDictionaries=
"0"
DefaultDictionary=
"application-level"
UseSingleDictionary=
"true"
transferred=
"true"
/>
<component
name=
"TaskManager"
>
<task
active=
"true"
id=
"Default"
summary=
"Default task"
>
<changelist
id=
"9ca737e0-d8bf-4a68-bfb8-89308a7b8ac5"
name=
"Changes"
comment=
""
/>
<created>
1713269694077
</created>
<option
name=
"number"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<updated>
1713269694077
</updated>
</task>
<servers
/>
</component>
</project>
\ No newline at end of file
MongoDB-Reader/pom.xml
deleted
100644 → 0
View file @
5ef39394
<?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>
MongoDB-Reader
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<properties>
<maven.compiler.source>
17
</maven.compiler.source>
<maven.compiler.target>
17
</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<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
MongoDB-Reader/src/main/java/org/example/Main.java
deleted
100644 → 0
View file @
5ef39394
package
org
.
example
;
import
com.mongodb.ClientSessionOptions
;
import
com.mongodb.ReadPreference
;
import
com.mongodb.WriteConcern
;
import
com.mongodb.client.*
;
import
com.mongodb.connection.ClusterDescription
;
import
org.bson.Document
;
import
org.bson.conversions.Bson
;
import
java.util.List
;
import
static
com
.
mongodb
.
client
.
model
.
Filters
.
eq
;
public
class
Main
{
///use mongos
private
static
final
String
Mongo_URL
=
"mongodb://192.168.184.11:27117"
;
/*+
"192.168.184.11:27027," +
"192.168.184.11:27037" +
"/?replicaSet=rs1";*/
private
static
final
String
DB_Name
=
"sample_mflix"
;
private
static
final
Double
Min_gpa
=
90.0
;
public
static
void
main
(
String
[]
args
)
{
/*String cousre = args[0];
String student = args[1];*/
String
cousre
=
"Math"
;
String
student
=
"Abd"
;
double
grade
=
200
;
MongoDatabase
DB
=
connectToMongoDB
();
//enroll(DB , cousre , student , 15 , grade);
//enable Sharding
DB
.
runCommand
(
new
Document
(
"enable sharding"
,
DB_Name
));
//create collection
DB
.
createCollection
(
"movies"
);
//shard a collection
DB
.
runCommand
(
new
Document
(
"shardCollection"
,
DB_Name
+
"."
+
"movies"
)
.
append
(
"key"
,
new
Document
(
"_id"
,
"hashed"
)));
}
private
static
void
enroll
(
MongoDatabase
DB
,
String
course
,
String
student
,
int
age
,
double
gpa
)
{
/*if (!isValid(DB , course))
{
System.out.println("Not Valid Course");
return;
}*/
MongoCollection
<
Document
>
collection
=
DB
.
getCollection
(
course
)
.
withWriteConcern
(
WriteConcern
.
MAJORITY
)
.
withReadPreference
(
ReadPreference
.
primaryPreferred
());
if
(
collection
.
find
(
eq
(
"name"
,
student
)).
first
()
!=
null
)
{
System
.
out
.
println
(
"Student : "
+
student
+
" already exists"
);
return
;
}
if
(
gpa
<
Min_gpa
)
{
System
.
out
.
println
(
"Please Improve Grade"
);
return
;
}
collection
.
insertOne
(
new
Document
(
"name"
,
student
).
append
(
"age"
,
age
).
append
(
"gpa"
,
gpa
));
System
.
out
.
println
(
"Success!!"
);
for
(
Document
doc
:
collection
.
find
())
{
System
.
out
.
println
(
doc
);
}
}
private
static
boolean
isValid
(
MongoDatabase
DB
,
String
course
)
{
for
(
String
co
:
DB
.
listCollectionNames
())
{
if
(
co
.
equals
(
course
))
return
true
;
}
return
false
;
}
private
static
MongoDatabase
connectToMongoDB
()
{
MongoClient
mongoClient
=
MongoClients
.
create
(
Mongo_URL
);
return
mongoClient
.
getDatabase
(
DB_Name
);
}
}
\ No newline at end of file
MongoDB-Reader/src/main/resources/log4j.properties
deleted
100644 → 0
View file @
5ef39394
# 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
MongoDB-Reader/target/classes/log4j.properties
deleted
100644 → 0
View file @
5ef39394
# 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
MongoDB-Reader/target/classes/org/example/Main.class
deleted
100644 → 0
View file @
5ef39394
File deleted
Report.docx
View file @
0d3be7b4
No preview for this file type
Report.pdf
0 → 100644
View file @
0d3be7b4
File added
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