or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

analysis-framework.mdconfiguration.mdindex.mdprofiling.mdquery-services.mdremote-communication.mdsource-processing.mdstorage-layer.md

configuration.mddocs/

0

# Configuration

1

2

The SkyWalking configuration system provides centralized management of server settings, component library catalogs, entity naming rules, downsampling configurations, and service hierarchies. It supports dynamic configuration updates and pluggable configuration sources.

3

4

## Core Configuration Services

5

6

### ConfigService

7

8

Central service for general configuration management and dynamic updates.

9

10

```java { .api }

11

public class ConfigService implements Service {

12

13

/**

14

* Gets configuration value by key

15

* @param key Configuration key

16

* @return Configuration value or null if not found

17

*/

18

public String getConfigValue(String key);

19

20

/**

21

* Gets configuration value with default fallback

22

* @param key Configuration key

23

* @param defaultValue Default value if key not found

24

* @return Configuration value or default

25

*/

26

public String getConfigValue(String key, String defaultValue);

27

28

/**

29

* Gets integer configuration value

30

* @param key Configuration key

31

* @param defaultValue Default integer value

32

* @return Integer configuration value

33

*/

34

public int getIntValue(String key, int defaultValue);

35

36

/**

37

* Gets boolean configuration value

38

* @param key Configuration key

39

* @param defaultValue Default boolean value

40

* @return Boolean configuration value

41

*/

42

public boolean getBooleanValue(String key, boolean defaultValue);

43

44

/**

45

* Gets long configuration value

46

* @param key Configuration key

47

* @param defaultValue Default long value

48

* @return Long configuration value

49

*/

50

public long getLongValue(String key, long defaultValue);

51

52

/**

53

* Sets configuration value dynamically

54

* @param key Configuration key

55

* @param value Configuration value

56

*/

57

public void setConfigValue(String key, String value);

58

59

/**

60

* Registers configuration change listener

61

* @param key Configuration key to monitor

62

* @param listener Change listener callback

63

*/

64

public void registerConfigListener(String key, ConfigChangeListener listener);

65

66

/**

67

* Unregisters configuration change listener

68

* @param key Configuration key

69

* @param listener Listener to remove

70

*/

71

public void unregisterConfigListener(String key, ConfigChangeListener listener);

72

73

/**

74

* Reloads configuration from source

75

* @throws ConfigException If reload fails

76

*/

77

public void reload() throws ConfigException;

78

79

/**

80

* Gets all configuration keys

81

* @return Set of all configuration keys

82

*/

83

public Set<String> getAllKeys();

84

}

85

```

86

87

### NamingControl

88

89

Service for entity naming rules and normalization.

90

91

```java { .api }

92

public class NamingControl {

93

94

/**

95

* Normalizes service name according to naming rules

96

* @param serviceName Original service name

97

* @return Normalized service name

98

*/

99

public String formatServiceName(String serviceName);

100

101

/**

102

* Normalizes instance name according to naming rules

103

* @param instanceName Original instance name

104

* @return Normalized instance name

105

*/

106

public String formatInstanceName(String instanceName);

107

108

/**

109

* Normalizes endpoint name according to naming rules

110

* @param endpointName Original endpoint name

111

* @return Normalized endpoint name

112

*/

113

public String formatEndpointName(String endpointName);

114

115

/**

116

* Checks if service name needs normalization

117

* @param serviceName Service name to check

118

* @return True if normalization required

119

*/

120

public boolean needsNormalization(String serviceName);

121

122

/**

123

* Gets maximum allowed name length

124

* @return Maximum name length

125

*/

126

public int getMaxNameLength();

127

128

/**

129

* Gets naming rules configuration

130

* @return Naming rules settings

131

*/

132

public NamingRules getNamingRules();

133

134

/**

135

* Updates naming rules dynamically

136

* @param rules New naming rules

137

*/

138

public void updateNamingRules(NamingRules rules);

139

}

140

```

141

142

### DownSamplingConfigService

143

144

Service for managing downsampling configuration and time precision settings.

145

146

```java { .api }

147

public class DownSamplingConfigService implements Service {

148

149

/**

150

* Gets enabled downsampling levels

151

* @return List of active downsampling levels

152

*/

153

public List<DownSampling> getDownSamplingLevels();

154

155

/**

156

* Checks if specific downsampling level is enabled

157

* @param downSampling Downsampling level to check

158

* @return True if enabled

159

*/

160

public boolean isDownSamplingEnabled(DownSampling downSampling);

161

162

/**

163

* Gets data retention period for downsampling level

164

* @param downSampling Downsampling level

165

* @return Retention period in days

166

*/

167

public int getDataRetentionDays(DownSampling downSampling);

168

169

/**

170

* Gets time bucket format for downsampling level

171

* @param downSampling Downsampling level

172

* @return Time bucket format pattern

173

*/

174

public String getTimeBucketFormat(DownSampling downSampling);

175

176

/**

177

* Enables downsampling level

178

* @param downSampling Downsampling level to enable

179

*/

180

public void enableDownSampling(DownSampling downSampling);

181

182

/**

183

* Disables downsampling level

184

* @param downSampling Downsampling level to disable

185

*/

186

public void disableDownSampling(DownSampling downSampling);

187

188

/**

189

* Updates retention configuration

190

* @param downSampling Downsampling level

191

* @param retentionDays New retention period in days

192

*/

193

public void updateRetention(DownSampling downSampling, int retentionDays);

194

195

/**

196

* Gets downsampling configuration

197

* @return Complete downsampling configuration

198

*/

199

public DownSamplingConfig getConfig();

200

}

201

```

202

203

### HierarchyDefinitionService

204

205

Service for managing service hierarchy configurations and relationships.

206

207

```java { .api }

208

public class HierarchyDefinitionService implements Service {

209

210

/**

211

* Gets hierarchy definition for service

212

* @param serviceId Service identifier

213

* @return Hierarchy definition or null if not found

214

*/

215

public HierarchyDefinition getHierarchyDefinition(String serviceId);

216

217

/**

218

* Gets all hierarchy layers

219

* @return List of available hierarchy layers

220

*/

221

public List<String> getAllLayers();

222

223

/**

224

* Gets services in specific hierarchy layer

225

* @param layer Hierarchy layer name

226

* @return List of services in layer

227

*/

228

public List<String> getServicesInLayer(String layer);

229

230

/**

231

* Gets parent service in hierarchy

232

* @param serviceId Child service identifier

233

* @return Parent service identifier or null

234

*/

235

public String getParentService(String serviceId);

236

237

/**

238

* Gets child services in hierarchy

239

* @param serviceId Parent service identifier

240

* @return List of child service identifiers

241

*/

242

public List<String> getChildServices(String serviceId);

243

244

/**

245

* Sets service hierarchy relationship

246

* @param childServiceId Child service identifier

247

* @param parentServiceId Parent service identifier

248

* @param layer Hierarchy layer

249

*/

250

public void setHierarchyRelationship(String childServiceId, String parentServiceId, String layer);

251

252

/**

253

* Removes service from hierarchy

254

* @param serviceId Service identifier to remove

255

*/

256

public void removeFromHierarchy(String serviceId);

257

258

/**

259

* Updates hierarchy definition

260

* @param serviceId Service identifier

261

* @param definition New hierarchy definition

262

*/

263

public void updateHierarchyDefinition(String serviceId, HierarchyDefinition definition);

264

}

265

```

266

267

## Component Library Configuration

268

269

### IComponentLibraryCatalogService

270

271

Interface for component library catalog management.

272

273

```java { .api }

274

public interface IComponentLibraryCatalogService extends Service {

275

276

/**

277

* Gets component definition by ID

278

* @param componentId Component identifier

279

* @return Component definition or null if not found

280

*/

281

ComponentDefinition getComponentDefinition(int componentId);

282

283

/**

284

* Gets component definition by name

285

* @param componentName Component name

286

* @return Component definition or null if not found

287

*/

288

ComponentDefinition getComponentDefinition(String componentName);

289

290

/**

291

* Gets all registered components

292

* @return List of all component definitions

293

*/

294

List<ComponentDefinition> getAllComponents();

295

296

/**

297

* Gets components by category

298

* @param category Component category (database, cache, mq, etc.)

299

* @return List of components in category

300

*/

301

List<ComponentDefinition> getComponentsByCategory(String category);

302

303

/**

304

* Registers new component definition

305

* @param definition Component definition to register

306

* @return Generated component ID

307

*/

308

int registerComponent(ComponentDefinition definition);

309

310

/**

311

* Updates existing component definition

312

* @param componentId Component identifier

313

* @param definition Updated component definition

314

*/

315

void updateComponent(int componentId, ComponentDefinition definition);

316

317

/**

318

* Removes component from catalog

319

* @param componentId Component identifier to remove

320

*/

321

void removeComponent(int componentId);

322

323

/**

324

* Checks if component exists

325

* @param componentId Component identifier

326

* @return True if component exists

327

*/

328

boolean exists(int componentId);

329

}

330

```

331

332

### ComponentLibraryCatalogService

333

334

Default implementation of component library catalog service.

335

336

```java { .api }

337

public class ComponentLibraryCatalogService implements IComponentLibraryCatalogService {

338

339

private Map<Integer, ComponentDefinition> componentsById;

340

private Map<String, ComponentDefinition> componentsByName;

341

342

@Override

343

public ComponentDefinition getComponentDefinition(int componentId);

344

345

@Override

346

public ComponentDefinition getComponentDefinition(String componentName);

347

348

@Override

349

public List<ComponentDefinition> getAllComponents();

350

351

@Override

352

public List<ComponentDefinition> getComponentsByCategory(String category);

353

354

@Override

355

public int registerComponent(ComponentDefinition definition);

356

357

@Override

358

public void updateComponent(int componentId, ComponentDefinition definition);

359

360

@Override

361

public void removeComponent(int componentId);

362

363

@Override

364

public boolean exists(int componentId);

365

366

/**

367

* Loads component definitions from configuration file

368

* @param configFile Configuration file path

369

* @throws ConfigException If loading fails

370

*/

371

public void loadFromConfig(String configFile) throws ConfigException;

372

373

/**

374

* Saves component definitions to configuration file

375

* @param configFile Configuration file path

376

* @throws ConfigException If saving fails

377

*/

378

public void saveToConfig(String configFile) throws ConfigException;

379

380

/**

381

* Gets next available component ID

382

* @return Next component ID

383

*/

384

protected int getNextComponentId();

385

}

386

```

387

388

## Configuration Data Types

389

390

### NamingRules

391

392

Configuration for entity naming rules and constraints.

393

394

```java { .api }

395

public class NamingRules {

396

397

private int maxServiceNameLength;

398

private int maxInstanceNameLength;

399

private int maxEndpointNameLength;

400

private boolean normalizeServiceName;

401

private boolean normalizeInstanceName;

402

private boolean normalizeEndpointName;

403

private String serviceNamePattern;

404

private String instanceNamePattern;

405

private String endpointNamePattern;

406

private List<String> forbiddenServiceNames;

407

private List<String> forbiddenInstanceNames;

408

409

/**

410

* Gets maximum service name length

411

* @return Maximum length

412

*/

413

public int getMaxServiceNameLength();

414

415

/**

416

* Sets maximum service name length

417

* @param maxServiceNameLength Maximum length

418

*/

419

public void setMaxServiceNameLength(int maxServiceNameLength);

420

421

/**

422

* Checks if service name normalization is enabled

423

* @return True if normalization enabled

424

*/

425

public boolean isNormalizeServiceName();

426

427

/**

428

* Gets service name validation pattern

429

* @return Regex pattern for service names

430

*/

431

public String getServiceNamePattern();

432

433

/**

434

* Gets forbidden service names

435

* @return List of forbidden names

436

*/

437

public List<String> getForbiddenServiceNames();

438

439

/**

440

* Validates service name against rules

441

* @param serviceName Service name to validate

442

* @return True if valid

443

*/

444

public boolean isValidServiceName(String serviceName);

445

446

/**

447

* Validates instance name against rules

448

* @param instanceName Instance name to validate

449

* @return True if valid

450

*/

451

public boolean isValidInstanceName(String instanceName);

452

453

/**

454

* Validates endpoint name against rules

455

* @param endpointName Endpoint name to validate

456

* @return True if valid

457

*/

458

public boolean isValidEndpointName(String endpointName);

459

}

460

```

461

462

### DownSamplingConfig

463

464

Configuration for downsampling levels and retention policies.

465

466

```java { .api }

467

public class DownSamplingConfig {

468

469

private Map<DownSampling, Boolean> enabledLevels;

470

private Map<DownSampling, Integer> retentionDays;

471

private Map<DownSampling, String> timeBucketFormats;

472

473

/**

474

* Checks if downsampling level is enabled

475

* @param level Downsampling level

476

* @return True if enabled

477

*/

478

public boolean isEnabled(DownSampling level);

479

480

/**

481

* Enables or disables downsampling level

482

* @param level Downsampling level

483

* @param enabled True to enable, false to disable

484

*/

485

public void setEnabled(DownSampling level, boolean enabled);

486

487

/**

488

* Gets retention period for downsampling level

489

* @param level Downsampling level

490

* @return Retention period in days

491

*/

492

public int getRetentionDays(DownSampling level);

493

494

/**

495

* Sets retention period for downsampling level

496

* @param level Downsampling level

497

* @param days Retention period in days

498

*/

499

public void setRetentionDays(DownSampling level, int days);

500

501

/**

502

* Gets time bucket format for level

503

* @param level Downsampling level

504

* @return Time bucket format pattern

505

*/

506

public String getTimeBucketFormat(DownSampling level);

507

508

/**

509

* Gets all enabled downsampling levels

510

* @return List of enabled levels

511

*/

512

public List<DownSampling> getEnabledLevels();

513

}

514

```

515

516

### ComponentDefinition

517

518

Definition of a component in the component library catalog.

519

520

```java { .api }

521

public class ComponentDefinition {

522

523

private int id;

524

private String name;

525

private String category;

526

private String description;

527

private String version;

528

private Map<String, String> properties;

529

private List<String> supportedLanguages;

530

private boolean deprecated;

531

532

/**

533

* Gets component ID

534

* @return Component identifier

535

*/

536

public int getId();

537

538

/**

539

* Sets component ID

540

* @param id Component identifier

541

*/

542

public void setId(int id);

543

544

/**

545

* Gets component name

546

* @return Component name

547

*/

548

public String getName();

549

550

/**

551

* Sets component name

552

* @param name Component name

553

*/

554

public void setName(String name);

555

556

/**

557

* Gets component category

558

* @return Component category (database, cache, mq, http, etc.)

559

*/

560

public String getCategory();

561

562

/**

563

* Sets component category

564

* @param category Component category

565

*/

566

public void setCategory(String category);

567

568

/**

569

* Gets component description

570

* @return Component description

571

*/

572

public String getDescription();

573

574

/**

575

* Gets component version

576

* @return Component version

577

*/

578

public String getVersion();

579

580

/**

581

* Gets component properties

582

* @return Map of component properties

583

*/

584

public Map<String, String> getProperties();

585

586

/**

587

* Gets supported programming languages

588

* @return List of supported languages

589

*/

590

public List<String> getSupportedLanguages();

591

592

/**

593

* Checks if component is deprecated

594

* @return True if deprecated

595

*/

596

public boolean isDeprecated();

597

598

/**

599

* Sets component as deprecated

600

* @param deprecated True to mark as deprecated

601

*/

602

public void setDeprecated(boolean deprecated);

603

}

604

```

605

606

### HierarchyDefinition

607

608

Definition of service hierarchy relationships and metadata.

609

610

```java { .api }

611

public class HierarchyDefinition {

612

613

private String serviceId;

614

private String layer;

615

private String parentServiceId;

616

private List<String> childServiceIds;

617

private Map<String, String> metadata;

618

private int level;

619

620

/**

621

* Gets service identifier

622

* @return Service ID

623

*/

624

public String getServiceId();

625

626

/**

627

* Sets service identifier

628

* @param serviceId Service ID

629

*/

630

public void setServiceId(String serviceId);

631

632

/**

633

* Gets hierarchy layer

634

* @return Layer name (auto, k8s, mesh, etc.)

635

*/

636

public String getLayer();

637

638

/**

639

* Sets hierarchy layer

640

* @param layer Layer name

641

*/

642

public void setLayer(String layer);

643

644

/**

645

* Gets parent service identifier

646

* @return Parent service ID or null if root

647

*/

648

public String getParentServiceId();

649

650

/**

651

* Sets parent service identifier

652

* @param parentServiceId Parent service ID

653

*/

654

public void setParentServiceId(String parentServiceId);

655

656

/**

657

* Gets child service identifiers

658

* @return List of child service IDs

659

*/

660

public List<String> getChildServiceIds();

661

662

/**

663

* Adds child service to hierarchy

664

* @param childServiceId Child service ID to add

665

*/

666

public void addChildService(String childServiceId);

667

668

/**

669

* Removes child service from hierarchy

670

* @param childServiceId Child service ID to remove

671

*/

672

public void removeChildService(String childServiceId);

673

674

/**

675

* Gets hierarchy metadata

676

* @return Map of metadata properties

677

*/

678

public Map<String, String> getMetadata();

679

680

/**

681

* Gets hierarchy level (depth from root)

682

* @return Hierarchy level

683

*/

684

public int getLevel();

685

686

/**

687

* Sets hierarchy level

688

* @param level Hierarchy level

689

*/

690

public void setLevel(int level);

691

}

692

```

693

694

## Configuration Listeners

695

696

### ConfigChangeListener

697

698

Interface for receiving configuration change notifications.

699

700

```java { .api }

701

public interface ConfigChangeListener {

702

703

/**

704

* Called when configuration value changes

705

* @param key Configuration key that changed

706

* @param oldValue Previous configuration value

707

* @param newValue New configuration value

708

*/

709

void onConfigChanged(String key, String oldValue, String newValue);

710

711

/**

712

* Called when configuration is added

713

* @param key Configuration key that was added

714

* @param value New configuration value

715

*/

716

void onConfigAdded(String key, String value);

717

718

/**

719

* Called when configuration is removed

720

* @param key Configuration key that was removed

721

* @param oldValue Previous configuration value

722

*/

723

void onConfigRemoved(String key, String oldValue);

724

}

725

```

726

727

### ComponentCatalogListener

728

729

Interface for component catalog change notifications.

730

731

```java { .api }

732

public interface ComponentCatalogListener {

733

734

/**

735

* Called when component is added to catalog

736

* @param definition Component definition that was added

737

*/

738

void onComponentAdded(ComponentDefinition definition);

739

740

/**

741

* Called when component is updated in catalog

742

* @param oldDefinition Previous component definition

743

* @param newDefinition Updated component definition

744

*/

745

void onComponentUpdated(ComponentDefinition oldDefinition, ComponentDefinition newDefinition);

746

747

/**

748

* Called when component is removed from catalog

749

* @param definition Component definition that was removed

750

*/

751

void onComponentRemoved(ComponentDefinition definition);

752

}

753

```

754

755

## Configuration Exceptions

756

757

### ConfigException

758

759

Base exception for configuration-related errors.

760

761

```java { .api }

762

public class ConfigException extends Exception {

763

764

/**

765

* Creates configuration exception with message

766

* @param message Error message

767

*/

768

public ConfigException(String message);

769

770

/**

771

* Creates configuration exception with message and cause

772

* @param message Error message

773

* @param cause Underlying cause

774

*/

775

public ConfigException(String message, Throwable cause);

776

}

777

```

778

779

### NamingViolationException

780

781

Exception for entity naming rule violations.

782

783

```java { .api }

784

public class NamingViolationException extends ConfigException {

785

786

private String entityName;

787

private String violationType;

788

789

/**

790

* Creates naming violation exception

791

* @param entityName Entity name that violates rules

792

* @param violationType Type of violation

793

* @param message Error message

794

*/

795

public NamingViolationException(String entityName, String violationType, String message);

796

797

/**

798

* Gets entity name that caused violation

799

* @return Entity name

800

*/

801

public String getEntityName();

802

803

/**

804

* Gets violation type

805

* @return Violation type (length, pattern, forbidden, etc.)

806

*/

807

public String getViolationType();

808

}

809

```

810

811

## Usage Examples

812

813

### Basic Configuration Management

814

815

```java

816

// Get configuration service

817

ConfigService configService = moduleDefineHolder.find(CoreModule.NAME)

818

.provider().getService(ConfigService.class);

819

820

// Read configuration values

821

String storageType = configService.getConfigValue("storage.type", "elasticsearch");

822

int maxConnections = configService.getIntValue("storage.max-connections", 100);

823

boolean enableDebug = configService.getBooleanValue("debug.enabled", false);

824

825

// Set configuration values dynamically

826

configService.setConfigValue("analysis.batch-size", "1000");

827

828

// Listen for configuration changes

829

configService.registerConfigListener("storage.type", new ConfigChangeListener() {

830

@Override

831

public void onConfigChanged(String key, String oldValue, String newValue) {

832

System.out.println("Storage type changed from " + oldValue + " to " + newValue);

833

// Reinitialize storage connection

834

reinitializeStorage(newValue);

835

}

836

837

@Override

838

public void onConfigAdded(String key, String value) {

839

System.out.println("New configuration added: " + key + " = " + value);

840

}

841

842

@Override

843

public void onConfigRemoved(String key, String oldValue) {

844

System.out.println("Configuration removed: " + key);

845

}

846

});

847

```

848

849

### Entity Naming Control

850

851

```java

852

// Get naming control service

853

NamingControl namingControl = moduleDefineHolder.find(CoreModule.NAME)

854

.provider().getService(NamingControl.class);

855

856

// Configure naming rules

857

NamingRules rules = new NamingRules();

858

rules.setMaxServiceNameLength(200);

859

rules.setNormalizeServiceName(true);

860

rules.setServiceNamePattern("^[a-zA-Z0-9_-]+$");

861

rules.setForbiddenServiceNames(Arrays.asList("system", "internal", "admin"));

862

863

namingControl.updateNamingRules(rules);

864

865

// Format entity names

866

String originalServiceName = "My Service With Spaces!";

867

String normalizedServiceName = namingControl.formatServiceName(originalServiceName);

868

System.out.println("Normalized: " + normalizedServiceName); // "My_Service_With_Spaces"

869

870

// Validate names

871

if (namingControl.needsNormalization("problematic-service-name!")) {

872

String normalized = namingControl.formatServiceName("problematic-service-name!");

873

System.out.println("Service name normalized to: " + normalized);

874

}

875

```

876

877

### Downsampling Configuration

878

879

```java

880

// Get downsampling configuration service

881

DownSamplingConfigService downsamplingService = moduleDefineHolder.find(CoreModule.NAME)

882

.provider().getService(DownSamplingConfigService.class);

883

884

// Check enabled levels

885

List<DownSampling> enabledLevels = downsamplingService.getDownSamplingLevels();

886

System.out.println("Enabled downsampling levels: " + enabledLevels);

887

888

// Configure retention policies

889

downsamplingService.updateRetention(DownSampling.Minute, 3); // 3 days

890

downsamplingService.updateRetention(DownSampling.Hour, 30); // 30 days

891

downsamplingService.updateRetention(DownSampling.Day, 365); // 1 year

892

893

// Enable/disable levels

894

downsamplingService.enableDownSampling(DownSampling.Hour);

895

downsamplingService.disableDownSampling(DownSampling.Day);

896

897

// Check specific level

898

if (downsamplingService.isDownSamplingEnabled(DownSampling.Minute)) {

899

int retentionDays = downsamplingService.getDataRetentionDays(DownSampling.Minute);

900

System.out.println("Minute data retained for " + retentionDays + " days");

901

}

902

```

903

904

### Component Library Management

905

906

```java

907

// Get component library service

908

IComponentLibraryCatalogService componentService = moduleDefineHolder.find(CoreModule.NAME)

909

.provider().getService(IComponentLibraryCatalogService.class);

910

911

// Register new component

912

ComponentDefinition mysqlComponent = new ComponentDefinition();

913

mysqlComponent.setName("MySQL");

914

mysqlComponent.setCategory("database");

915

mysqlComponent.setDescription("MySQL relational database");

916

mysqlComponent.setVersion("8.0");

917

mysqlComponent.setSupportedLanguages(Arrays.asList("Java", "Python", "PHP", "Node.js"));

918

919

Map<String, String> properties = new HashMap<>();

920

properties.put("port", "3306");

921

properties.put("protocol", "mysql");

922

mysqlComponent.setProperties(properties);

923

924

int componentId = componentService.registerComponent(mysqlComponent);

925

System.out.println("Registered MySQL component with ID: " + componentId);

926

927

// Query components

928

List<ComponentDefinition> databaseComponents =

929

componentService.getComponentsByCategory("database");

930

931

for (ComponentDefinition component : databaseComponents) {

932

System.out.println("Database component: " + component.getName() +

933

" v" + component.getVersion());

934

}

935

936

// Update component

937

ComponentDefinition existingComponent = componentService.getComponentDefinition("MySQL");

938

if (existingComponent != null) {

939

existingComponent.setVersion("8.0.30");

940

componentService.updateComponent(existingComponent.getId(), existingComponent);

941

}

942

```

943

944

### Service Hierarchy Management

945

946

```java

947

// Get hierarchy service

948

HierarchyDefinitionService hierarchyService = moduleDefineHolder.find(CoreModule.NAME)

949

.provider().getService(HierarchyDefinitionService.class);

950

951

// Define service hierarchy

952

hierarchyService.setHierarchyRelationship(

953

"user-service", // child

954

"web-gateway", // parent

955

"k8s" // layer

956

);

957

958

hierarchyService.setHierarchyRelationship(

959

"order-service", // child

960

"web-gateway", // parent

961

"k8s" // layer

962

);

963

964

// Query hierarchy

965

String parentService = hierarchyService.getParentService("user-service");

966

System.out.println("Parent of user-service: " + parentService);

967

968

List<String> childServices = hierarchyService.getChildServices("web-gateway");

969

System.out.println("Children of web-gateway: " + childServices);

970

971

// Get hierarchy definition

972

HierarchyDefinition userServiceHierarchy =

973

hierarchyService.getHierarchyDefinition("user-service");

974

975

if (userServiceHierarchy != null) {

976

System.out.println("Service: " + userServiceHierarchy.getServiceId());

977

System.out.println("Layer: " + userServiceHierarchy.getLayer());

978

System.out.println("Level: " + userServiceHierarchy.getLevel());

979

System.out.println("Parent: " + userServiceHierarchy.getParentServiceId());

980

}

981

982

// List all layers

983

List<String> allLayers = hierarchyService.getAllLayers();

984

System.out.println("Available hierarchy layers: " + allLayers);

985

986

// Get services in specific layer

987

List<String> k8sServices = hierarchyService.getServicesInLayer("k8s");

988

System.out.println("Services in k8s layer: " + k8sServices);

989

```

990

991

## Core Configuration Types

992

993

```java { .api }

994

/**

995

* Configuration module definition

996

*/

997

public class ConfigModule extends ModuleDefine {

998

public static final String NAME = "configuration";

999

1000

@Override

1001

public String name();

1002

1003

@Override

1004

public Class[] services();

1005

}

1006

1007

/**

1008

* Configuration source enumeration

1009

*/

1010

public enum ConfigSource {

1011

FILE, ENVIRONMENT, SYSTEM_PROPERTY, DATABASE, REMOTE

1012

}

1013

1014

/**

1015

* Configuration change event

1016

*/

1017

public class ConfigChangeEvent {

1018

private String key;

1019

private String oldValue;

1020

private String newValue;

1021

private ConfigSource source;

1022

private long timestamp;

1023

1024

public String getKey();

1025

public String getOldValue();

1026

public String getNewValue();

1027

public ConfigSource getSource();

1028

public long getTimestamp();

1029

}

1030

```