Exemple #1
0
func (s *Store) deleteSeries(database string, seriesKeys []string, min, max int64) error {
	db := s.databaseIndexes[database]
	if db == nil {
		return influxql.ErrDatabaseNotFound(database)
	}

	for _, sh := range s.shards {
		if sh.database != database {
			continue
		}
		if err := sh.DeleteSeriesRange(seriesKeys, min, max); err != nil {
			return err
		}

		// The keys we passed in may be fully deleted from the shard, if so,
		// we need to remove the shard from all the meta data indexes
		existing, err := sh.ContainsSeries(seriesKeys)
		if err != nil {
			return err
		}

		for k, exists := range existing {
			if !exists {
				db.UnassignShard(k, sh.id)
			}
		}
	}

	return nil
}
Exemple #2
0
func (s *Store) deleteSeries(database string, seriesKeys []string, min, max int64) error {
	db := s.databaseIndexes[database]
	if db == nil {
		return influxql.ErrDatabaseNotFound(database)
	}

	s.mu.RLock()
	shards := s.filterShards(func(sh *Shard) bool {
		return sh.database == database
	})
	s.mu.RUnlock()

	return s.walkShards(shards, func(sh *Shard) error {
		if sh.database != database {
			return nil
		}
		if err := sh.DeleteSeriesRange(seriesKeys, min, max); err != nil {
			return err
		}

		// The keys we passed in may be fully deleted from the shard, if so,
		// we need to remove the shard from all the meta data indexes
		existing, err := sh.ContainsSeries(seriesKeys)
		if err != nil {
			return err
		}

		for k, exists := range existing {
			if !exists {
				db.UnassignShard(k, sh.id)
			}
		}
		return nil
	})
}
func (e *StatementExecutor) executeDropMeasurementStatement(stmt *influxql.DropMeasurementStatement, database string) error {
	if dbi := e.MetaClient.Database(database); dbi == nil {
		return influxql.ErrDatabaseNotFound(database)
	}

	// Locally drop the measurement
	return e.TSDBStore.DeleteMeasurement(database, stmt.Name)
}
func (e *StatementExecutor) executeDeleteSeriesStatement(stmt *influxql.DeleteSeriesStatement, database string) error {
	if dbi := e.MetaClient.Database(database); dbi == nil {
		return influxql.ErrDatabaseNotFound(database)
	}

	// Convert "now()" to current time.
	stmt.Condition = influxql.Reduce(stmt.Condition, &influxql.NowValuer{Now: time.Now().UTC()})

	// Locally delete the series.
	return e.TSDBStore.DeleteSeries(database, stmt.Sources, stmt.Condition)
}
func (e *StatementExecutor) executeDropSeriesStatement(stmt *influxql.DropSeriesStatement, database string) error {
	if dbi := e.MetaClient.Database(database); dbi == nil {
		return influxql.ErrDatabaseNotFound(database)
	}

	// Check for time in WHERE clause (not supported).
	if influxql.HasTimeExpr(stmt.Condition) {
		return errors.New("DROP SERIES doesn't support time in WHERE clause")
	}

	// Locally drop the series.
	return e.TSDBStore.DeleteSeries(database, stmt.Sources, stmt.Condition)
}
Exemple #6
0
func (s *Store) deleteSeries(database string, seriesKeys []string) error {
	if _, ok := s.databaseIndexes[database]; !ok {
		return influxql.ErrDatabaseNotFound(database)
	}

	for _, sh := range s.shards {
		if sh.database != database {
			continue
		}
		if err := sh.DeleteSeries(seriesKeys); err != nil {
			return err
		}
	}
	return nil
}
Exemple #7
0
func (e *QueryExecutor) executeDropMeasurementStatement(stmt *influxql.DropMeasurementStatement, database string) error {
	if dbi, err := e.MetaClient.Database(database); err != nil {
		return err
	} else if dbi == nil {
		return influxql.ErrDatabaseNotFound(database)
	}

	// Locally drop the measurement
	if err := e.TSDBStore.DeleteMeasurement(database, stmt.Name); err != nil {
		return err
	}

	// Execute the statement on the other data nodes in the cluster.
	return e.MetaExecutor.ExecuteStatement(stmt, database)
}
Exemple #8
0
// Run runs the specified continuous query, or all CQs if none is specified.
func (s *Service) Run(database, name string, t time.Time) error {
	var dbs []meta.DatabaseInfo

	if database != "" {
		// Find the requested database.
		db, err := s.MetaClient.Database(database)
		if err != nil {
			return err
		} else if db == nil {
			return influxql.ErrDatabaseNotFound(database)
		}
		dbs = append(dbs, *db)
	} else {
		// Get all databases.
		var err error
		dbs, err = s.MetaClient.Databases()
		if err != nil {
			return err
		}
	}

	// Loop through databases.
	s.mu.Lock()
	defer s.mu.Unlock()
	for _, db := range dbs {
		// Loop through CQs in each DB executing the ones that match name.
		for _, cq := range db.ContinuousQueries {
			if name == "" || cq.Name == name {
				// Remove the last run time for the CQ
				id := fmt.Sprintf("%s:%s", db.Name, cq.Name)
				if _, ok := s.lastRuns[id]; ok {
					delete(s.lastRuns, id)
				}
			}
		}
	}

	// Signal the background routine to run CQs.
	s.RunCh <- &RunRequest{Now: t}

	return nil
}
Exemple #9
0
func (e *QueryExecutor) executeDropSeriesStatement(stmt *influxql.DropSeriesStatement, database string) error {
	if dbi, err := e.MetaClient.Database(database); err != nil {
		return err
	} else if dbi == nil {
		return influxql.ErrDatabaseNotFound(database)
	}

	// Check for time in WHERE clause (not supported).
	if influxql.HasTimeExpr(stmt.Condition) {
		return errors.New("DROP SERIES doesn't support time in WHERE clause")
	}

	// Locally drop the series.
	if err := e.TSDBStore.DeleteSeries(database, stmt.Sources, stmt.Condition); err != nil {
		return err
	}

	// Execute the statement on the other data nodes in the cluster.
	return e.MetaExecutor.ExecuteStatement(stmt, database)
}