예제 #1
0
// See the ingester.ResultIngester interface.
func (i GoldIngester) Ingest(tt *ingester.TileTracker, opener ingester.Opener, fileInfo *ingester.ResultsFileLocation, counter metrics.Counter) error {
	r, err := opener()
	if err != nil {
		return err
	}
	defer util.Close(r)

	res, err := ParseDMResultsFromReader(r)
	if err != nil {
		return err
	}

	// Run the pre-ingestion hook.
	if i.preIngestionHook != nil {
		if err := i.preIngestionHook(res); err != nil {
			return fmt.Errorf("Error running pre-ingestion hook: %s", err)
		}
	}

	if res.GitHash != "" {
		glog.Infof("Got Git hash: %s", res.GitHash)
		if err := tt.Move(res.GitHash); err != nil {
			return fmt.Errorf("Failed to move to correct Tile: %s: %s", res.GitHash, err)
		}
		addResultToTile(res, tt.Tile(), tt.Offset(res.GitHash), counter)
	} else {
		return fmt.Errorf("Missing hash.")
	}

	return nil
}
예제 #2
0
// See the ingester.ResultIngester interface.
func (i NanoBenchIngester) Ingest(tt *ingester.TileTracker, opener ingester.Opener, fileInfo *ingester.ResultsFileLocation, counter metrics.Counter) error {
	r, err := opener()
	if err != nil {
		return err
	}

	benchData, err := ParseBenchDataFromReader(r)
	if err != nil {
		return err
	}

	// Move to the correct Tile for the Git hash.
	hash := benchData.Hash
	if hash == "" {
		return fmt.Errorf("Found invalid hash: %s", hash)
	}

	if err := tt.Move(hash); err != nil {
		return fmt.Errorf("UpdateCommitInfo Move(%s) failed with: %s", hash, err)
	}

	// Add the parsed data to the Tile.
	addBenchDataToTile(benchData, tt.Tile(), tt.Offset(hash), counter)
	return nil
}