megoldas a loggerre, egyeb javitasok
authorTamas Jung <tamasjung@gmail.com>
Fri, 16 Apr 2010 12:29:41 +0000 (14:29 +0200)
committerTamas Jung <tamasjung@gmail.com>
Fri, 16 Apr 2010 12:29:41 +0000 (14:29 +0200)
ruby/test.rb
src/arcclientc.cpp
src/arcclientc.h
src/common_utils.h
src/logger.h
src/prefix_header.h
src/submit.cpp
src/submit.h

index e83dcf4..3ede909 100644 (file)
@@ -1,8 +1,10 @@
 require 'ffi'
 require 'pp'
 
+ENV["ARC_LOCATION"] = "/opt/local"
+
 jobdesc = File.read "/Users/tamas/quick/arc/arex/simple.jsdl"
-args = [""]#enelkul lemaradt a -c, az optionparser nyilvan levagja
+args = [""] #optparser cuts the first arg
 args += "-c ARC1:https://localhost:60000/arex -e".split
 args << jobdesc
 
@@ -29,10 +31,19 @@ argv.write_array_of_pointer(args.map {|arg| FFI::MemoryPointer.from_string(arg.t
 
 p "the version is: " + ArcClientCLibrary.initialize
 
-p "args:" + args.inspect
-result = ArcClientCLibrary.submit(args.size, argv)
 
-p (ArcClientCLibrary::SubmitResult.new(result))[:message].to_s
-p (ArcClientCLibrary::SubmitResult.new(result))[:job_id].to_s
+p "args:" + args.inspect
+2.times do |i|
+       p "running No. #{i}"
+       
+       argv = FFI::MemoryPointer.new(:pointer, args.size)
+       argv.write_array_of_pointer(args.map {|arg| FFI::MemoryPointer.from_string(arg.to_s)}) 
+       #you can not share argv between submit calls, i do not know why (it might be freed by optparser?)
+       
+       result = ArcClientCLibrary.submit(args.size, argv)
+       submitResult = ArcClientCLibrary::SubmitResult.new(result)
+       p (submitResult)[:message].to_s
+       p (submitResult)[:job_id].to_s
+end
 
 p "Done."
\ No newline at end of file
index 457c060..21125c3 100644 (file)
 #include "arc_libs.h"
 #include "common_utils.h"
 
-#pragma GCC visibility push(default)
-extern "C" {
+
 
 char* initialize(){
        
-
+       setlocale(LC_ALL, "");//TBD: do we need this?
+               
+       
+       static Arc::LogStream  logcerr(std::cerr);
+       
+       logcerr.setFormat(Arc::ShortFormat);
+       Arc::Logger::getRootLogger().addDestination(logcerr);
+       Arc::Logger::getRootLogger().setThreshold(Arc::DEBUG);
+       
        
        return new_str(ARCCLIENTC_VERSION);
 }
-}      
-#pragma GCC visibility pop
+
 
 
index 9dc89a9..4f3ae4a 100644 (file)
 
 #define ARCCLIENTC_VERSION "0.1"
 #include "submit.h"
+#include "common_utils.h"
 /* Things below are exported */
-#pragma GCC visibility push(default)
-extern "C" {
 
 
-char* initialize();
+
+PUBLIC_C char* initialize();
        
-}
 
-#pragma GCC visibility pop
 #endif
index 0e187b7..6e6b54e 100644 (file)
@@ -12,5 +12,6 @@
 #include <sstream>
 char* ostringstream2cstring(std::ostringstream& string);       
 char* new_str(const char* str);
+#define PUBLIC_C extern "C" __attribute__ ((visibility("default")))
 
 #endif
\ No newline at end of file
index b4f5533..9c0e3e7 100644 (file)
@@ -11,8 +11,8 @@
 #define logger_
 
 #include "arc_libs.h"
-static Arc::Logger* logger; 
-
+//static Arc::Logger* logger; 
+static Arc::Logger logger(Arc::Logger::getRootLogger(), "arcclientc");
 #endif
 
 
index ee574e4..91b8698 100644 (file)
@@ -3,7 +3,8 @@
  *  arcclientc
  *
  *  Created by Tamas Jung on 4/8/10.
- *  Copyright 2010 Apple. All rights reserved.
+ *  Copyright 2010 Interface Kft. All rights reserved.
  *
  */
 
+
index 981a164..bd25b14 100644 (file)
@@ -8,9 +8,8 @@
  */
 
 #include "submit.h"
-#include "common_utils.h"
 #include "logger.h"
-#include "config.h"
+#include "config.h" //TBD: Kell ez?
 // -*- indent-tabs-mode: nil -*-
 
 #ifdef HAVE_CONFIG_H
 #include <unistd.h>
 
 #include "arc_libs.h"
-#pragma GCC visibility push(default)
-extern "C" {
+
+
 submit_result_t* submit(int argc, char **argv) {
        
        
        
-       setlocale(LC_ALL, "");//TBD: do we need this?
-       logger = new Arc::Logger(Arc::Logger::getRootLogger(), "arcclientc");
-       //TBD:
-       
-       
-       
-       Arc::LogStream logcerr(std::cerr);
-       logcerr.setFormat(Arc::ShortFormat);
-       Arc::Logger::getRootLogger().addDestination(logcerr);
-       Arc::Logger::getRootLogger().setThreshold(Arc::DEBUG);
-       
-       
-       
-       /* Arc::LogStream logcerr = Arc::LogStream(std::cerr);//TBD on the stack?
-       logcerr.setFormat(Arc::ShortFormat);
-       Arc::Logger::getRootLogger().addDestination(logcerr);
-
-       Arc::Logger::getRootLogger().setThreshold(Arc::DEBUG);//TODO: read threshold from env */
-       
-       Arc::ArcLocation::Init("/opt/local");//set ARC_LOCATION !!!!!!
-       
        
        
        
@@ -190,7 +168,7 @@ submit_result_t* submit(int argc, char **argv) {
                result->message = ostringstream2cstring(sstream);
                return result;
        }
-       logger->msg(Arc::INFO, "Broker %s loaded", usercfg.Broker().first);
+       logger.msg(Arc::INFO, "Broker %s loaded", usercfg.Broker().first);
        
                
        ChosenBroker->PreFilterTargets(targen.ModifyFoundTargets(), jobdesc);
@@ -212,18 +190,18 @@ submit_result_t* submit(int argc, char **argv) {
                //submit the job
                Arc::URL jobid = submitter->Submit(jobdesc, *target);
                if (!jobid) {
-                       logger->msg(Arc::INFO, "Submission to %s failed, trying next target", target->url.str());
+                       logger.msg(Arc::INFO, "Submission to %s failed, trying next target", target->url.str());
                        continue;
                }
                
                ChosenBroker->RegisterJobsubmission();
                result->job_id = new_str(jobid.str().c_str());
-               logger->msg(Arc::DEBUG, "Job submitted with jobid: %s", jobid.str());
+               logger.msg(Arc::DEBUG, "Job submitted with jobid: %s", jobid.str());
                
                break;
        } //end loop over all possible targets
        
        return result;
 }
-}
+
 
index 987ce44..a94efe5 100644 (file)
 #ifndef submit_
 #define submit_
 
-#pragma GCC visibility push(default)
-extern "C" {
+#include "common_utils.h"
 
 typedef struct{
        char* message;//might be NULL
        char* job_id;//might be NULL
 } submit_result_t;
 
-submit_result_t* submit(int argc, char **argv);
-}
-#pragma GCC visibility pop
+PUBLIC_C submit_result_t* submit(int argc, char **argv);
+
 #endif