Skip to content

Commit

Permalink
[Improvement] use "storage_cooldown_seconds" property when storage me…
Browse files Browse the repository at this point in the history
…dium is SSD (apache#7532)

Refer to this issue apache#7528

When setting property `default_storage_medium=ssd` and `storage_cooldown_second=xxx` in `fe.conf`
`cooldownTime=System.currentTimeMillis()+ storage_cooldown_second` , not always `MAX_COOLDOWN_TIME_MS`
  • Loading branch information
chovy-3012 authored Jan 4, 2022
1 parent bf4a867 commit 5c104ec
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ private DataProperty() {
}

public DataProperty(TStorageMedium medium) {
this(medium, MAX_COOLDOWN_TIME_MS);
this.storageMedium = medium;
if (medium == TStorageMedium.SSD) {
long currentTimeMs = System.currentTimeMillis();
this.cooldownTimeMs = currentTimeMs + Config.storage_cooldown_second * 1000L;
} else {
this.cooldownTimeMs = MAX_COOLDOWN_TIME_MS;
}
}

public DataProperty(TStorageMedium medium, long cooldown) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.doris.catalog;

import org.apache.doris.common.Config;
import org.apache.doris.thrift.TStorageMedium;
import org.junit.Assert;
import org.junit.Test;

public class DataPropertyTest {

@Test
public void tesCooldownTimeMs() throws Exception {
Config.default_storage_medium = "ssd";
DataProperty dataProperty = DataProperty.DEFAULT_DATA_PROPERTY;
Assert.assertNotEquals(DataProperty.MAX_COOLDOWN_TIME_MS, dataProperty.getCooldownTimeMs());

dataProperty = new DataProperty(TStorageMedium.SSD);
Assert.assertNotEquals(DataProperty.MAX_COOLDOWN_TIME_MS, dataProperty.getCooldownTimeMs());

dataProperty = new DataProperty(TStorageMedium.SSD, System.currentTimeMillis() + 24 * 3600 * 1000L);
Assert.assertEquals(System.currentTimeMillis() + 24 * 3600 * 1000L, dataProperty.getCooldownTimeMs());

dataProperty = new DataProperty(TStorageMedium.HDD);
Assert.assertEquals(DataProperty.MAX_COOLDOWN_TIME_MS, dataProperty.getCooldownTimeMs());
}
}

0 comments on commit 5c104ec

Please sign in to comment.