Skip to content

Commit

Permalink
bug fix...
Browse files Browse the repository at this point in the history
bug :- long time to process data server queue in main server flow.
  • Loading branch information
NeelPatel21 committed Mar 24, 2017
1 parent aaeee56 commit 8cb5dbb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
Binary file modified ProgramTester.jar
Binary file not shown.
5 changes: 4 additions & 1 deletion nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/src/net/logSer/LogHandler.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/src/net/mainSer/SerDetails.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/src/net/mainSer/userStatus/UserStatusLog.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/src/net/flow/mainSerFlows/MainSerFlow.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/test/net/flow/MainLogFlowTest.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/test/net/flow/MainDataFlowTest.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/src/programtester/config/Configurator.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/src/lib/ui/gui/QuestionPage.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/test/net/flow/MainSerFlowTest.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/src/net/mainSer/userStatus/UserStatus.java</file>
<file>file:/C:/My%20folder/Fun/Data/Program%20Tester/src/net/mainSer/userStatus/UserFactory.java</file>
</group>
</open-files>
</project-private>
1 change: 1 addition & 0 deletions src/net/logSer/LogHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public static boolean setBackupLog(String url){
return false;
}
} catch (Exception ex) {
System.out.println("Setting backup server fail..");
return false;
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/net/mainSer/SerDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @author Neel Patel
*/
public class SerDetails {
private static long QUE_LEN = 6;
private SerDetails(){}
private static IntRemoteLog log;
private static IntDataSer mainDataSer;
Expand Down Expand Up @@ -67,6 +68,7 @@ public static synchronized String getMainDataSer(){
*/
private synchronized static String findDataSer(){
IntDataSer d=dataSer.keySet().parallelStream()
//.filter(i->isAlive(i))
.reduce((x,y)->{
if(dataSer.get(x)>dataSer.get(y))
return y;
Expand Down Expand Up @@ -100,7 +102,7 @@ private static boolean isAlive(IntDataSer d){
* @return URI of log server, null if log sever is not reachable
exception occur
*/
public static synchronized String getLogSer(){
public static String getLogSer(){
try {
if(log.aya())
return log.toUrl();
Expand Down Expand Up @@ -159,6 +161,14 @@ public static boolean setLogSer(String url){
reason.
*/
public static boolean registerDataSer(String url){
System.out.println("data ser reg :- "+url);
long c = new HashSet<IntDataSer>(dataSer.keySet()).parallelStream().peek(i->{
if(!isAlive(i)){
dataSer.remove(i);
}
}).count();
if(c>QUE_LEN)
return false;
try {
IntDataSer ds=(IntDataSer)Naming.lookup(url);
if(ds.aya()){
Expand Down Expand Up @@ -207,7 +217,7 @@ public synchronized static boolean registerMainDataSer(String url){

public synchronized static Set<String> getAllDataSer(){
Set<String> s=new HashSet<String>();
new HashSet<IntDataSer>(dataSer.keySet()).stream().forEach(i->{
new HashSet<IntDataSer>(dataSer.keySet()).parallelStream().forEach(i->{
try {
if(isAlive(i)){
s.add(i.toUrl());
Expand Down
11 changes: 7 additions & 4 deletions src/net/mainSer/userStatus/UserFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public static synchronized String init(String lp){
IntRemoteLog ir=new UserStatusLog();
int port=getDefaultRMIPort();
String uri=UrlTools.registerObj(ir, port,"userState");
((UserStatusLog)ir).setUrl(uri);

readProgramDetails();
readUserDetail(getDefaultUserDetailPath());
System.out.println("user factory uri :- "+uri);
Expand Down Expand Up @@ -152,7 +154,7 @@ public static synchronized IntUserStatus getUser(String uName){
* @param log String of log
* @return true if processed successfully, false otherwise.
*/
public synchronized static boolean processLog(String log){
public static synchronized boolean processLog(String log){
try{
String uName=LogTools.getLogProperty(log, "username");
//String passwd=LogTools.getLogProperty(log, "password");
Expand All @@ -171,6 +173,7 @@ else if(status==TEST_FILE_ERROR)
return u.update(pid, 0);
else return false;
}catch(Exception ex){
System.out.println("Log Processing fail :- "+log);
return false;
}
}
Expand All @@ -181,7 +184,7 @@ else if(status==TEST_FILE_ERROR)
* @param pid programId.
* @return credit of the program.
*/
public static synchronized int getCredit(long pid){
public static int getCredit(long pid){
return problems.stream().filter(i->i.getProgramID()==pid)
.mapToInt(i->i.getCredit()).findAny().orElse(-1);
}
Expand All @@ -194,8 +197,8 @@ public static void proBack(String uri){
try {
IntLogProc lp=(IntLogProc)Naming.lookup(uri);
List<String> l=lp.getLogs(null,null);
l.stream().forEach(i->processLog(i));
System.out.println("Log recovered");
long c=l.stream().peek(i->processLog(i)).count();
System.out.println("Log recovered "+c);
} catch (Exception ex) {
System.err.println("Error in log recovery!!");
}
Expand Down

0 comments on commit 8cb5dbb

Please sign in to comment.