-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from estigma88/initial-refactor
Adding gradle
- Loading branch information
Showing
160 changed files
with
18,417 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Java class files | ||
*.class | ||
|
||
# Intellij project files | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
#Gradle | ||
.gradletasknamecache | ||
.gradle/ | ||
build/ | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apply plugin: 'java' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apply plugin: 'java' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile project(':communication') | ||
compile project(':lookup-service') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Chord project implement of lookup algorithm Chord | ||
* Copyright (C) 2010 Daniel Pelaez, Daniel Lopez, Hector Hurtado | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package co.edu.uniquindio.chord; | ||
|
||
import co.edu.uniquindio.chord.node.ChordNode; | ||
import co.edu.uniquindio.overlay.OverlayNode; | ||
import co.edu.uniquindio.utils.hashing.Key; | ||
|
||
/** | ||
* The {@code Chord} interface defines the basic methods for creating the node | ||
* on chord's ring. | ||
* | ||
* @author Daniel Pelaez | ||
* @author Hector Hurtado | ||
* @author Daniel Lopez | ||
* @version 1.0, 17/06/2010 | ||
* @since 1.0 | ||
* @see ChordNode | ||
* @see Key | ||
* @see OverlayNode | ||
*/ | ||
public interface Chord extends OverlayNode { | ||
/** | ||
* Finds the node on the ring that is the successor of the given key. | ||
* | ||
* @param id | ||
* The key to find | ||
* @return A {@link Key} that is the successor for the id. | ||
*/ | ||
public Key lookUp(Key id); | ||
|
||
/** | ||
* Gets the {@link Key} of the chord node. | ||
* | ||
* @return The {@link Key} of the chord node. | ||
*/ | ||
public Key getKey(); | ||
} |
60 changes: 60 additions & 0 deletions
60
chord/src/main/java/co/edu/uniquindio/chord/ChordException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Chord project implement of lookup algorithm Chord | ||
* Copyright (C) 2010 Daniel Pelaez, Daniel Lopez, Hector Hurtado | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package co.edu.uniquindio.chord; | ||
|
||
import co.edu.uniquindio.overlay.OverlayException; | ||
|
||
/** | ||
* The <code>ChordException</code> class handles a exception, that could happen | ||
* when trying to make functions en layer Chord. | ||
* | ||
* @author Daniel Pelaez | ||
* @author Hector Hurtado | ||
* @author Daniel Lopez | ||
* @version 1.0, 17/06/2010 | ||
* @since 1.0 | ||
*/ | ||
public class ChordException extends OverlayException { | ||
/** | ||
* Serial | ||
*/ | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* Builds a exception by message | ||
* | ||
* @param message | ||
* Message | ||
*/ | ||
public ChordException(String message) { | ||
super(message); | ||
} | ||
|
||
/** | ||
* Builds a exception by message and throwable | ||
* | ||
* @param message | ||
* Message | ||
* @param throwable | ||
* Exception or error | ||
*/ | ||
public ChordException(String message, Throwable throwable) { | ||
super(message, throwable); | ||
} | ||
} |
215 changes: 215 additions & 0 deletions
215
chord/src/main/java/co/edu/uniquindio/chord/configurations/ChordProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
/* | ||
* Chord project implement of lookup algorithm Chord | ||
* Copyright (C) 2010 Daniel Pelaez, Daniel Lopez, Hector Hurtado | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1-b02-fcs | ||
* See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> | ||
* Any modifications to this file will be lost upon recompilation of the source schema. | ||
* Generated on: 2002.01.01 at 02:49:03 AM COT | ||
*/ | ||
|
||
package co.edu.uniquindio.chord.configurations; | ||
|
||
import java.io.File; | ||
import java.net.URISyntaxException; | ||
import java.security.CodeSource; | ||
|
||
import javax.xml.bind.JAXBContext; | ||
import javax.xml.bind.JAXBException; | ||
import javax.xml.bind.Unmarshaller; | ||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import javax.xml.bind.annotation.XmlType; | ||
|
||
import co.edu.uniquindio.utils.logger.LoggerDHT; | ||
|
||
/** | ||
* The <code>ChordProperties</code> class storage all properties of | ||
* configuration for Chord algorithm | ||
* <p> | ||
* Java class for anonymous complex type. | ||
* | ||
* <p> | ||
* The following schema fragment specifies the expected content contained within | ||
* this class. | ||
* | ||
* <pre> | ||
* <complexType> | ||
* <complexContent> | ||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> | ||
* <sequence> | ||
* <element ref="{http://www.DHT-UQ.org/chord}time"/> | ||
* <element ref="{http://www.DHT-UQ.org/chord}successorList"/> | ||
* </sequence> | ||
* </restriction> | ||
* </complexContent> | ||
* </complexType> | ||
* </pre> | ||
* | ||
* @author Daniel Pelaez | ||
* @author Hector Hurtado | ||
* @author Daniel Lopez | ||
* @version 1.0, 17/06/2010 | ||
* @since 1.0 | ||
*/ | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
@XmlType(name = "", propOrder = { "time", "successorList" }) | ||
@XmlRootElement(name = "chord") | ||
public class ChordProperties { | ||
|
||
/** | ||
* Logger | ||
*/ | ||
private static final LoggerDHT logger = LoggerDHT | ||
.getLogger(ChordProperties.class); | ||
|
||
/** | ||
* Sigle ChordProperties instance | ||
*/ | ||
private static ChordProperties chordProperties; | ||
|
||
/** | ||
* Package that contains mapped class to XML | ||
*/ | ||
private static final String PACKAGE = "co.edu.uniquindio.chord.configurations"; | ||
|
||
/** | ||
* Path where is the properties file named chord.xml | ||
*/ | ||
private static final String FILE = "resources/chord_properties/chord.xml"; | ||
|
||
/** | ||
* Load all properties from properties file in XML | ||
* | ||
* @throws ChordPropertiesException | ||
* throw when error occur | ||
*/ | ||
private void load() throws ChordPropertiesException { | ||
try { | ||
CodeSource codeSource = ChordProperties.class.getProtectionDomain() | ||
.getCodeSource(); | ||
File jarFile = new File(codeSource.getLocation().toURI().getPath()); | ||
|
||
File jarDir = jarFile.getParentFile(); | ||
|
||
File propFile = null; | ||
if (jarDir != null && jarDir.isDirectory()) { | ||
propFile = new File(jarDir, FILE); | ||
} | ||
|
||
JAXBContext jContext = JAXBContext.newInstance(PACKAGE); | ||
Unmarshaller u = jContext.createUnmarshaller(); | ||
|
||
chordProperties = (ChordProperties) u.unmarshal(propFile); | ||
|
||
if (chordProperties.getTime().getStableRing() < 100) { | ||
throw new ChordPropertiesException( | ||
"The property chord.time.stableRing not should is menor to 100"); | ||
} | ||
|
||
logger.info("Load property chord.time.stableRing= " | ||
+ chordProperties.getTime().getStableRing()); | ||
|
||
if (chordProperties.getSuccessorList().getAmount() < 1) { | ||
throw new ChordPropertiesException( | ||
"The property chord.successorList.amount not should is menor to 1"); | ||
} | ||
|
||
logger.info("Load property chord.successorList.amount= " | ||
+ chordProperties.getSuccessorList().getAmount()); | ||
|
||
} catch (JAXBException e) { | ||
throw new ChordPropertiesException("Error reading file " + FILE, e); | ||
} catch (URISyntaxException e) { | ||
throw new ChordPropertiesException("Syntax error", e); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the single instance of chord properties | ||
* | ||
* @return ChordProperties Single instancia of chord properties | ||
* | ||
*/ | ||
public static ChordProperties getInstance() { | ||
if (chordProperties == null) { | ||
chordProperties = new ChordProperties(); | ||
try { | ||
chordProperties.load(); | ||
} catch (ChordPropertiesException e) { | ||
logger.fatal("Error loading file " + FILE, e); | ||
} | ||
} | ||
return chordProperties; | ||
} | ||
|
||
/** | ||
* Stabilized time | ||
*/ | ||
@XmlElement(required = true) | ||
protected Time time; | ||
|
||
/** | ||
* Successor list | ||
*/ | ||
@XmlElement(required = true) | ||
protected SuccessorList successorList; | ||
|
||
/** | ||
* Gets the value of the time property. | ||
* | ||
* @return possible object is {@link Time } | ||
* | ||
*/ | ||
public Time getTime() { | ||
return time; | ||
} | ||
|
||
/** | ||
* Sets the value of the time property. | ||
* | ||
* @param value | ||
* allowed object is {@link Time } | ||
* | ||
*/ | ||
public void setTime(Time value) { | ||
this.time = value; | ||
} | ||
|
||
/** | ||
* Gets the value of the successorList property. | ||
* | ||
* @return possible object is {@link SuccessorList } | ||
* | ||
*/ | ||
public SuccessorList getSuccessorList() { | ||
return successorList; | ||
} | ||
|
||
/** | ||
* Sets the value of the successorList property. | ||
* | ||
* @param value | ||
* allowed object is {@link SuccessorList } | ||
* | ||
*/ | ||
public void setSuccessorList(SuccessorList value) { | ||
this.successorList = value; | ||
} | ||
|
||
} |
Oops, something went wrong.