1818import net .imglib2 .type .numeric .real .FloatType ;
1919import net .imglib2 .util .Util ;
2020import net .preibisch .distribution .algorithm .blockmanager .block .BasicBlockInfo ;
21+ import net .preibisch .distribution .algorithm .clustering .kafka .KafkaManager ;
2122import net .preibisch .distribution .algorithm .clustering .scripting .TaskType ;
2223import net .preibisch .distribution .algorithm .controllers .items .BlocksMetaData ;
2324import net .preibisch .distribution .io .img .XMLFile ;
@@ -61,10 +62,12 @@ public Void call() throws Exception {
6162 return null ;
6263
6364 default :
65+ KafkaManager .error (id ,"Specify task" );
6466 System .out .println ("Error" );
6567 throw new Exception ("Specify task!" );
6668 }
6769 } catch (Exception e ) {
70+ KafkaManager .error (id ,e .toString ());
6871 System .out .println ("Error" );
6972 throw new Exception ("Specify task!" );
7073 }
@@ -73,42 +76,47 @@ public Void call() throws Exception {
7376
7477 public static void blockTask (String inputPath , String metadataPath , String outputPath , int id ) {
7578 try {
76- System . out . println ( "Start process: " + id );
79+ KafkaManager . log ( id , "Start process" );
7780// XMLFile inputFile = XMLFile.XMLFile(inputPath);
7881 BlocksMetaData md = BlocksMetaData .fromJson (metadataPath );
79- System . out . println ( "Got metadata !" );
82+ KafkaManager . log ( id , "Got metadata !" );
8083 BasicBlockInfo binfo = md .getBlocksInfo ().get (id );
81- System . out . println ( "Got block info !" );
84+ KafkaManager . log ( id , "Got block info !" );
8285 BoundingBox bb = new BoundingBox (Util .long2int (binfo .getMin ()), Util .long2int (binfo .getMax ()));
83- System . out . println ( "Bounding box created: " +bb .toString ());
86+ KafkaManager . log ( id , "Bounding box created: " +bb .toString ());
8487 List <ViewId > viewIds = md .getViewIds () ;
85- System . out . println ( "Got view ids " );
88+ KafkaManager . log ( id , "Got view ids " );
8689
8790 XMLFile inputFile = XMLFile .XMLFile (inputPath , bb , md .getDownsample () , viewIds );
8891
89- System . out . println ( "Input loaded. " );
92+ KafkaManager . log ( id , "Input loaded. " );
9093// XMLFile inputFile = XMLFile.XMLFile(inputPath);
9194 RandomAccessibleInterval <FloatType > block = inputFile .fuse (bb );
9295
93- System . out . println ( "Got block. " );
96+ KafkaManager . log ( id , "Got block. " );
9497 N5File outputFile = N5File .open (outputPath );
9598 outputFile .saveBlock (block , binfo .getGridOffset ());
96- System .out .println ("Task finished " +id );
99+ KafkaManager .log (id ,"Task finished " +id );
100+ KafkaManager .done (id ,"Task finished " +id );
97101 } catch (SpimDataException | IOException e ) {
98- // TODO Auto-generated catch block
102+ KafkaManager . error ( id , e . toString ());
99103 e .printStackTrace ();
100104 }
101105 }
102106
103107 public static void generateN5 (String inputPath , String metadataPath , String outputPath , int id ) {
104108 try {
109+ KafkaManager .log (id , "Start generate n5" );
105110 BlocksMetaData md = BlocksMetaData .fromJson (metadataPath );
106111 long [] dims = md .getDimensions ();
107112 int blockUnit = md .getBlockUnit ();
108113 N5File outputFile = new N5File (outputPath , dims ,blockUnit );
109114 outputFile .create ();
115+ KafkaManager .log (id , "N5 Generated" );
116+ KafkaManager .done (id , "N5 Generated" );
110117 } catch (JsonSyntaxException | JsonIOException | IOException e ) {
111- // TODO Auto-generated catch block
118+
119+ KafkaManager .error (id , e .toString ());
112120 e .printStackTrace ();
113121 }
114122 }
0 commit comments