Changeset 14


Ignore:
Timestamp:
08/22/11 10:42:49 (14 years ago)
Author:
mcichenski
Message:

merge gforge source into current svn

Location:
gssim/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • gssim/trunk/build.xml

    r5 r14  
    180180        </target> 
    181181 
     182        <target name="genWorkload"> 
     183                <available property="properties.file" type="file" file="${config}" value="${config}"/> 
     184                <antcall target="generateWorkload"/> 
     185        </target> 
     186         
     187        <target name="generateWorkload" depends="compile" if="properties.file"> 
     188                <echo message="Generating workload described in: ${properties.file}"/> 
     189                 
     190                <java classname="simulator.workload.generator.WorkloadGenerator" classpath="${build}/classes" fork="true"> 
     191                        <arg file="${properties.file}"/> 
     192                        <classpath> 
     193                                <path refid="class.path"/> 
     194                                <pathelement path="${jars}/commons-beanutils.jar"/> 
     195                                <pathelement path="${jars}/commons-digester-1.7.jar"/> 
     196                                <pathelement path="${jars}/junit-4.4.jar"/> 
     197                                <pathelement path="${jars}/log4j-1.2.13.jar"/> 
     198                                <pathelement path="${jars}/xalan-2.6.jar"/> 
     199                                <pathelement path="${jars}/xerces/xerces-2_9_0/xercesImpl.jar"/> 
     200                                <pathelement path="${jars}/xerces/xerces-2_9_0/xml-apis.jar"/> 
     201                                <dirset dir="properties" /> 
     202                        </classpath> 
     203                </java> 
     204        </target> 
     205         
    182206</project> 
  • gssim/trunk/daemon/Daemon.cpp

    r5 r14  
    2828#define EVENT_SIZE  ( sizeof (struct inotify_event) ) 
    2929#define EVENT_BUF_LEN     ( 1024 * ( EVENT_SIZE + 16 ) ) 
    30 #define RUNNING_DIR     "/opt/app/gssim/daemon" 
     30#define RUNNING_DIR     "/home/mcichenski/daemon" 
    3131#define LOCK_FILE       "daemon.lock" 
    3232#define LOG_FILE        "daemon.log" 
     
    3838char gssimdir[255]; 
    3939char gssimexecfile[255]; 
     40char gssimpropertyfile[255]; 
    4041char basedir[255]; 
    4142char msg[255]; 
     
    162163        if ( (fin.rdstate() & (ifstream::failbit | ifstream::eofbit)) != 0 ) 
    163164        { 
    164                 cerr << "Error while reading gssim dir" << endl; 
    165                 exit(-1); 
    166         } 
     165                cerr << "Error while reading gssim dir " << gssimdir << endl; 
     166                cerr << "config file: " << config_file << endl; 
     167                exit(-1); 
     168        } 
     169        strcpy(msg, "Gssim directory found: "); 
     170        strcat(msg, gssimdir); 
     171        log_message(LOG_FILE, msg); 
    167172 
    168173        fin.getline(gssimexecfile, 255); 
     
    172177                exit(-1); 
    173178        }        
    174          
     179        strcpy(msg, "Gssim exec file found: "); 
     180        strcat(msg, gssimexecfile); 
     181        log_message(LOG_FILE, msg); 
     182 
     183        fin.getline(gssimpropertyfile, 255); 
     184        if ( (fin.rdstate() & (ifstream::failbit | ifstream::eofbit)) != 0 ) 
     185        { 
     186                cerr << "Error while reading gssim property file name" << endl;; 
     187                exit(-1); 
     188        }        
     189        strcpy(msg, "Gssim property file found: "); 
     190        strcat(msg, gssimpropertyfile); 
     191        log_message(LOG_FILE, msg); 
     192 
    175193        fin.getline(basedir, 255); 
    176194        if ( (fin.rdstate() & (ifstream::failbit | ifstream::eofbit)) != 0 ) 
     
    179197                exit(-1); 
    180198        }        
     199        strcpy(msg, "Base watch directory found: "); 
     200        strcat(msg, basedir); 
     201        log_message(LOG_FILE, msg); 
    181202         
    182203        fin.close(); 
     
    202223         
    203224        strcpy(msg, "Directory "); 
    204         strcat(msg, basedir); 
     225        strcat(msg, paths[wd]); 
    205226        strcat(msg, " is added to watch list"); 
    206227        log_message(LOG_FILE, msg); 
     
    228249                                                strcat(msg, event->name); 
    229250                                                strcat(msg, " created."); 
    230                                                 log_message(LOG_FILE, msg);                                                              
    231  
    232                                                 char dir[255] = "\0"; 
    233                                                 strcat(dir, paths[event->wd]); 
     251                                                log_message(LOG_FILE, msg); 
     252 
     253                                                char dir[255]; 
     254                                                strcpy(dir, paths[event->wd]); 
    234255                                                strcat(dir, "/"); 
    235256                                                strcat(dir, event->name); 
    236257                                                wd = inotify_add_watch(fd, dir, IN_CREATE 
    237258                                                                | IN_CLOSE_WRITE); 
     259                                                paths[wd] = dir; 
    238260                                                                 
    239261                                                strcpy(msg, "Directory "); 
     
    241263                                                strcat(msg, " is added to watch list");                                                          
    242264                                                log_message(LOG_FILE, msg);                                                              
    243                                                                                                                  
    244                                                 paths[wd] = dir; 
     265 
     266                                                strcpy(msg, "wd: "); 
     267                                                char str[255] = "\0"; 
     268                                                sprintf(str, "%d", event->wd); 
     269                                                strcat(msg, str); 
     270                                                strcat(msg, " path: "); 
     271                                                strcat(msg, paths[event->wd]); 
     272                                                strcat(msg, " new_wd: "); 
     273                                                char str2[255] = "\0"; 
     274                                                sprintf(str2, "%d", wd); 
     275                                                strcat(msg, str2); 
     276                                                strcat(msg, " new_path: "); 
     277                                                strcat(msg, paths[wd]); 
     278                                                log_message(LOG_FILE, msg); 
    245279                                        } 
    246280                                } else if (event->mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) { 
     
    280314                                                        strcat(gssim, "/"); 
    281315                                                        strcat(gssim, gssimexecfile); 
     316                                                        char property[255] = "\0"; 
     317                                                        strcpy(property, gssimdir); 
     318                                                        strcat(property, "/"); 
     319                                                        strcat(property, gssimpropertyfile); 
    282320                                                        strcat(path, "/"); 
    283321                                                        strcat(path, name.c_str()); 
    284322                                                        cout << gssim << endl << path << endl; 
    285                                                         execl(gssim, "gssim", path, NULL); 
     323                                                        execl(gssim, "gssim", path, property, NULL); 
    286324                                                } else { 
    287325                                                        waitpid(pid, NULL, 0); 
  • gssim/trunk/daemon/daemon.config

    r5 r14  
    11/opt/app/gssim/ 
    22start-db-analyzer.sh 
     3properties.config 
    34/opt/app/gssim/results/ 
    45------------------------------ 
     
    671) directory in which gssim is installed 
    782) name of file that should be executed 
    8 3) base directory which should be watched 
     93) name of property file that should be loaded for db access 
     104) base directory which should be watched 
    911 
    1012Path to daemon running directory is precompiled 
  • gssim/trunk/db/gssim/db/analyzer/Analyzer.java

    r5 r14  
    133133        private Experiment experiment; 
    134134        private String userDN; 
    135         private Integer expNoInSeries; 
    136  
    137         public Analyzer(int n) throws InstantiationException, 
     135        private Integer totalSimulationRuns; 
     136        private Integer currentSimulationRun; 
     137 
     138        public Analyzer() throws InstantiationException, 
    138139                        IllegalAccessException, ClassNotFoundException { 
    139140 
    140                 expNoInSeries = n; 
    141141                jobID = new HashMap<Integer, Integer>(); 
    142142                taskID = new HashMap<Pair<Integer, Integer>, Integer>(); 
     
    154154                userDN = null; 
    155155                factory = new MySQLDAOFactory(); 
     156                totalSimulationRuns = 1; 
    156157        } 
    157158 
     
    170171                        InstantiationException, IllegalAccessException, 
    171172                        ClassNotFoundException { 
    172                 Analyzer analyzer = new Analyzer(1); 
     173                Analyzer analyzer = new Analyzer(); 
    173174                analyzer.run(args); 
    174175        } 
     
    206207                if (args.length < 1 || args.length > 3) 
    207208                        throw new RuntimeException( 
    208                                         "Program should be run with 1-4 arguments: " 
     209                                        "Program should be run with 1-3 arguments: " 
    209210                                                        + "*.tar file or directory with experiment results, " 
    210211                                                        + "encrypted or unencrypted properties file, " 
     
    217218                try { 
    218219 
    219                         if (gssimResults.getName().endsWith(".tar")) { 
    220  
    221                                 FileInputStream fileStream = new FileInputStream(gssimResults); 
    222                                 tarInputStream = new TarArchiveInputStream(fileStream); 
    223                                 prepareStreams(tarInputStream, config); 
    224  
    225                         } else if (gssimResults.isDirectory()) { 
    226  
    227                                 PrepareStreams(gssimResults, config); 
    228  
    229                         } else 
    230                                 throw new RuntimeException( 
    231                                                 "This program should be run with one argument: " 
    232                                                                 + "*.tar file or directory with experiment results"); 
    233  
    234                         checkFilesPresence(config); 
    235  
    236220                        connection = factory.createDBConnection(config.getDb(), config 
    237221                                        .getUser(), config.getPassword()); 
     
    239223                        connection.setAutoCommit(false); 
    240224 
    241                         setup(inputStreams.get("propertiesInputStream"), config); 
    242                         process(); 
    243  
     225                        currentSimulationRun = 0; 
     226                         
     227                        while (currentSimulationRun != totalSimulationRuns) 
     228                        { 
     229                                currentSimulationRun++; 
     230                                config.initFileNames(currentSimulationRun); 
     231                                if (gssimResults.getName().endsWith(".tar")) { 
     232         
     233                                        FileInputStream fileStream = new FileInputStream(gssimResults); 
     234                                        tarInputStream = new TarArchiveInputStream(fileStream); 
     235                                        prepareStreams(tarInputStream, config); 
     236         
     237                                } else if (gssimResults.isDirectory()) { 
     238         
     239                                        PrepareStreams(gssimResults, config); 
     240         
     241                                } else 
     242                                        throw new RuntimeException( 
     243                                                        "This program should be run with one argument: " 
     244                                                                        + "*.tar file or directory with experiment results"); 
     245         
     246                                checkFilesPresence(config); 
     247                                 
     248                                setup(inputStreams.get("propertiesInputStream"), config); 
     249                                process(); 
     250                        } 
    244251                        connection.commit(); 
    245252                        log.info("Database operations are commited"); 
     
    582589                } 
    583590 
    584                 if (properties.containsKey("experiment.id")) { 
     591                if (properties.containsKey("numberofsimulations")) 
     592                { 
     593                        totalSimulationRuns = Integer.parseInt((String) properties.get("numberofsimulations")); 
     594                } 
     595                 
     596                if (properties.containsKey("experiment.id") && currentSimulationRun == 1) { 
    585597                        experiment = new Experiment(); 
    586598                        experiment.setPK(Integer.parseInt((String) properties.get("experiment.id"))); 
     
    596608 
    597609                        configuration = new Configuration(); 
    598                         configurationDAO.insert(configuration, false); 
    599610 
    600611                        user = new User(); 
    601612                        user.setDN("unknown_user"); 
    602                         userDAO.insert(user, false); 
    603  
     613 
     614                        Integer metaExpId = null; 
     615                        String name = "experiment"; 
     616                         
     617                        if (properties.containsKey("experiment.id")) 
     618                        { 
     619                                experiment = new Experiment(); 
     620                                experiment.setPK(Integer.parseInt((String) properties.get("experiment.id"))); 
     621                                experiment = experimentDAO.select(experiment); 
     622                                 
     623                                metaExpId = experiment.getMetaexpId(); 
     624                                name = experiment.getName(); 
     625                                user.setId(experiment.getUserId()); 
     626                                configuration.setId(experiment.getConfigId()); 
     627                        } 
     628                        else 
     629                        { 
     630                                userDAO.insert(user, false); 
     631                                configurationDAO.insert(configuration, false); 
     632                        } 
     633                         
    604634                        experiment = new Experiment(); 
    605635                        experiment.setConfigId(configuration.getId()); 
    606636                        experiment.setUserId(user.getId()); 
    607637                        experiment.setCommissionDate(new Timestamp((new Date()).getTime())); 
    608                         experiment.setName("default-name"); 
     638                        experiment.setMetaexpId(metaExpId); 
     639                        experiment.setName(name+ "_" + currentSimulationRun.toString()); 
    609640                        experiment.setStatus("FINISHED"); 
    610641                        experimentDAO.insert(experiment, false); 
  • gssim/trunk/db/gssim/db/config/Config.java

    r5 r14  
    9494        }        
    9595         
     96        public void initFileNames(Integer simulationRun) 
     97        { 
     98                statsFile = "Stats_Simulation " + simulationRun.toString() + "_Simulation.txt"; 
     99                jobsFile = "Stats_Simulation " + simulationRun.toString() + "_Jobs.txt"; 
     100                tasksFile = "Stats_Simulation " + simulationRun.toString() + "_Raw_Tasks.txt"; 
     101                resourcesFile = "Stats_Simulation " + simulationRun.toString() + "_Raw_Resources.txt"; 
     102                energyFile = "Stats_Simulation " + simulationRun.toString() + "_Energy.txt"; 
     103                resourceLoadFile = "Stats_Simulation " + simulationRun.toString() + "_Resource_Load.txt"; 
     104                accumulatedResourcesFile = "Stats_Simulation " + simulationRun.toString() + "_Accumulated_Resources.txt"; 
     105                networkFile = "Stats_Simulation " + simulationRun.toString() + "_Network.txt"; 
     106                propertiesFile = "experiment.properties"; 
     107        } 
     108         
    96109        /** 
    97110         * Gets the stats file. 
  • gssim/trunk/db/gssim/db/config/MySQLConfig.java

    r5 r14  
    1212                super(propertiesPath); 
    1313                 
    14                 initOtherConfigParameters(); 
     14                initParameters(1); 
    1515        } 
    1616 
     
    2020                super(encryptedPropertiesPath, keyPath); 
    2121                 
    22                 initOtherConfigParameters(); 
     22                initParameters(1); 
    2323                 
    2424                System.out.println(user); 
     
    3232                db = "localhost:3306/gssim_results"; 
    3333                 
    34                 initOtherConfigParameters(); 
     34                initParameters(1); 
    3535        } 
    3636 
    37         private void initOtherConfigParameters() { 
    38                 statsFile = "Stats_Simulation 1_Simulation.txt"; 
    39                 jobsFile = "Stats_Simulation 1_Jobs.txt"; 
    40                 tasksFile = "Stats_Simulation 1_Raw_Tasks.txt"; 
    41                 resourcesFile = "Stats_Simulation 1_Raw_Resources.txt"; 
    42                 energyFile = "Stats_Simulation 1_Energy.txt"; 
    43                 resourceLoadFile = "Stats_Simulation 1_Resource_Load.txt"; 
    44                 accumulatedResourcesFile = "Stats_Simulation 1_Accumulated_Resources.txt"; 
    45                 networkFile = "Stats_Simulation 1_Network.txt"; 
    46                 propertiesFile = "experiment.properties"; 
     37        private void initParameters(Integer simulationRun) { 
     38                initFileNames(simulationRun); 
    4739 
    4840                extractDirectoryPath = null; 
     
    5042                propertiesIgnoreKeys = new ArrayList<String>(); 
    5143 
     44                //why this is specific to MySQLConfig implementation? 
    5245                propertiesIgnoreKeys.add("createstatistics.formatoutput"); 
    5346                propertiesIgnoreKeys.add("printhistory"); 
    54                 propertiesIgnoreKeys.add("readscenario.workloadfilename"); 
    5547                propertiesIgnoreKeys.add("readscenario.inputfolder"); 
    56                 propertiesIgnoreKeys.add("resdesc"); 
    5748                propertiesIgnoreKeys.add("stats.outputfolder"); 
    5849                propertiesIgnoreKeys.add("user.dn"); 
  • gssim/trunk/db/gssim/db/mysql/ExperimentStatsDAO.java

    r5 r14  
    5151        @Override 
    5252        protected PreparedStatementAdapter createSelectStmt() throws SQLException { 
    53                 String sql = "SELECT * FROM unit_details WHERE id = ? AND name = ?"; 
     53                String sql = "SELECT * FROM experiment_stats WHERE id = ? AND name = ?"; 
    5454                PreparedStatementAdapter stmt = new PreparedStatementAdapter(this 
    5555                                .getConnection().prepareStatement(sql)); 
  • gssim/trunk/db/gssim/db/mysql/ResourceAllTimelineDAO.java

    r5 r14  
    6464        } 
    6565 
     66        protected PreparedStatementAdapter createSumStmt() throws SQLException { 
     67                String sql = "SELECT timestamp, SUM(`usage`) as 'usage'" +  
     68                                        " FROM resource_allocation_timeline rat" + 
     69                                        " JOIN resource r ON r.PK = rat.fk_resource_id" + 
     70                                        " WHERE exp_id = ?" + 
     71                                        " AND (timestamp between ? AND ?)" + 
     72                                        " GROUP BY TIMESTAMP"; 
     73                PreparedStatementAdapter stmt = new PreparedStatementAdapter(this 
     74                                .getConnection().prepareStatement(sql)); 
     75                return stmt; 
     76        } 
     77         
    6678        @Override 
    6779        public boolean delete(ResourceAllTimeline obj, boolean commit) 
     
    204216                throw new NotImplemented(); 
    205217        } 
     218         
     219        public List<ResourceAllTimeline> sum(Finder finder) throws SQLException { 
     220 
     221                PreparedStatementAdapter stmt = createSumStmt(); 
     222                List<ResourceAllTimeline> list = new ArrayList<ResourceAllTimeline>(); 
     223 
     224                stmt.setInt(1, finder.getInteger("fkResourceId")); 
     225                stmt.setTimestamp(2, finder.getMinTimestamp("timestamp")); 
     226                stmt.setTimestamp(3, finder.getMaxTimestamp("timestamp")); 
     227                ResultSetAdapter result = new ResultSetAdapter(stmt.executeQuery()); 
     228 
     229                while (result.next()) { 
     230                        ResourceAllTimeline obj = new ResourceAllTimeline(); 
     231 
     232                        Timestamp timestamp = result.getTimestamp("timestamp"); 
     233                        Float usage = result.getFloatObj("usage"); 
     234 
     235                        obj.setTimestamp(timestamp); 
     236                        obj.setUsage(usage); 
     237 
     238                        list.add(obj); 
     239                } 
     240 
     241                return list; 
     242        } 
    206243 
    207244} 
  • gssim/trunk/db/gssim/db/mysql/ResourceEnTimelineDAO.java

    r5 r14  
    11package gssim.db.mysql; 
    22 
     3import gssim.db.dao.data.ResourceAllTimeline; 
    34import gssim.db.dao.data.ResourceEnTimeline; 
    45import gssim.db.find.Finder; 
     
    6364                return null; 
    6465        } 
     66         
     67        protected PreparedStatementAdapter createSumStmt() throws SQLException { 
     68                String sql = "SELECT timestamp, SUM(`usage`) as 'usage'" +  
     69                                        " FROM resource_energy_timeline rat" + 
     70                                        " JOIN resource r ON r.PK = rat.fk_resource_id" + 
     71                                        " WHERE exp_id = ?" + 
     72                                        " AND (timestamp between ? AND ?)" + 
     73                                        " GROUP BY TIMESTAMP"; 
     74                PreparedStatementAdapter stmt = new PreparedStatementAdapter(this 
     75                                .getConnection().prepareStatement(sql)); 
     76                return stmt; 
     77        } 
    6578 
    6679        @Override 
     
    204217                throw new NotImplemented(); 
    205218        } 
     219         
     220        public List<ResourceEnTimeline> sum(Finder finder) throws SQLException { 
     221 
     222                PreparedStatementAdapter stmt = createSumStmt(); 
     223                List<ResourceEnTimeline> list = new ArrayList<ResourceEnTimeline>(); 
     224 
     225                stmt.setInt(1, finder.getInteger("fkResourceId")); 
     226                stmt.setTimestamp(2, finder.getMinTimestamp("timestamp")); 
     227                stmt.setTimestamp(3, finder.getMaxTimestamp("timestamp")); 
     228                ResultSetAdapter result = new ResultSetAdapter(stmt.executeQuery()); 
     229 
     230                while (result.next()) { 
     231                        ResourceEnTimeline obj = new ResourceEnTimeline(); 
     232 
     233                        Timestamp timestamp = result.getTimestamp("timestamp"); 
     234                        Float usage = result.getFloatObj("usage"); 
     235 
     236                        obj.setTimestamp(timestamp); 
     237                        obj.setUsage(usage); 
     238 
     239                        list.add(obj); 
     240                } 
     241 
     242                return list; 
     243        } 
    206244 
    207245} 
Note: See TracChangeset for help on using the changeset viewer.