- Timestamp:
- 06/22/13 21:51:33 (11 years ago)
- Location:
- java/main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main
-
Property
svn:ignore
set to
target
-
Property
svn:ignore
set to
-
java/main/src/main/java/com/framsticks/diagnostics/DiagnosticsEndpoint.java
r77 r84 1 1 package com.framsticks.diagnostics; 2 2 3 import com.framsticks. core.Path;3 import com.framsticks.dumping.PrintWriterSink; 4 4 import com.framsticks.dumping.SaveStream; 5 5 import com.framsticks.observers.Endpoint; 6 import com.framsticks.dumping.PrintStreamSink;7 6 import com.framsticks.remote.RecursiveFetcher; 8 7 import com.framsticks.util.Logging; … … 13 12 import java.io.File; 14 13 import java.io.IOException; 15 import java.io.Print Stream;14 import java.io.PrintWriter; 16 15 import java.text.SimpleDateFormat; 17 16 import java.util.Date; … … 22 21 public class DiagnosticsEndpoint extends Endpoint { 23 22 24 private final static Logger LOGGER= Logger.getLogger(DiagnosticsEndpoint.class.getName());23 private final static Logger log = Logger.getLogger(DiagnosticsEndpoint.class.getName()); 25 24 26 25 27 28 29 26 public DiagnosticsEndpoint() { 27 super(); 28 } 30 29 31 32 33 34 30 @Override 31 public Diagnostics getObserver() { 32 return (Diagnostics)observer; 33 } 35 34 36 35 37 38 protected void configure() {39 super.configure();36 @Override 37 public void start() { 38 super.start(); 40 39 41 42 43 44 40 if (getObserver().dumpsInterval != null) { 41 new PeriodicTask(instance, getObserver().dumpsInterval * 1000) { 42 @Override 43 public void run() { 45 44 46 LOGGER.info("starting periodic dump");47 new RecursiveFetcher(instance, new Path(instance, "/"), new StateFunctor() {48 49 50 if (Logging.log(LOGGER, "recursively fetch", instance, e)) {51 52 53 54 LOGGER.info("instance resolved, saving");55 56 57 58 new SaveStream(new PrintStreamSink(new PrintStream(file)), instance, new Path(instance, "/"), new StateFunctor() {59 60 61 Logging.log(LOGGER, "periodic dump in " + fileName + " of", DiagnosticsEndpoint.this.instance, e);62 63 64 65 66 LOGGER.info("failed to initiate dump: " + ex);67 68 45 log.info("starting periodic dump"); 46 new RecursiveFetcher(instance, instance.getRootPath(), new StateFunctor() { 47 @Override 48 public void call(Exception e) { 49 if (Logging.log(log, "recursively fetch", instance, e)) { 50 again(); 51 return; 52 } 53 log.info("instance resolved, saving"); 54 try { 55 final String fileName = getObserver().dumpsPath + "/" + instance + "_" + new SimpleDateFormat(getObserver().dumpsFormat).format(new Date()) + ".param"; 56 File file = new File(fileName); 57 new SaveStream(new PrintWriterSink(new PrintWriter(file)), instance, instance.getRootPath(), new StateFunctor() { 58 @Override 59 public void call(Exception e) { 60 Logging.log(log, "periodic dump in " + fileName + " of", DiagnosticsEndpoint.this.instance, e); 61 again(); 62 } 63 }); 64 } catch (IOException ex) { 65 log.info("failed to initiate dump: " + ex); 66 again(); 67 } 69 68 70 71 69 } 70 }); 72 71 73 72 74 75 76 77 73 } 74 }; 75 } 76 } 78 77 79 80 81 82 83 84 78 /* 79 @Override 80 public void onChange(Path path) { 81 super.onChange(path); //To change body of overridden methods use File | Settings | File Templates. 82 } 83 */ 85 84 }
Note: See TracChangeset
for help on using the changeset viewer.