grafana 批量視圖備份及恢復(含數據源)

一、grafana 批量視圖備份

import requests
import json
import urllib3
import osfrom requests.auth import HTTPBasicAuthfilename_folders_map = "folders_map.json"
type_folder = "dash-folder"
type_dashboard = "dash-db"# Grafana服務器地址及API密鑰
grafana_url = "http://127.0.0.1:30301/api"
api_key = "YOUR_API_KEY"
username = "admin"
passwd = "admin123"
requests.packages.urllib3.disable_warnings()
new_grafana_url = "https://127.0.0.1:30301/api"
new_es_url = "https://quickstart-es-data-nodes.es8:9200"
new_es_passwd = "new_es_passwd "headers = {'Content-Type': 'application/json'
}# 獲取數據源列表
def get_datasources():response = requests.get(f'{grafana_url}/datasources', headers=headers, auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")def save_datasource_detail(datasource_id):response = requests.get(f'{grafana_url}/datasources/{datasource_id}', headers=headers,auth=HTTPBasicAuth(username, passwd), verify=False)if response.status_code == 200:ret_json = json.loads(response.text)print(ret_json)name = ret_json["name"]# 打開文件(若不存在則創建)并寫入JSON數據with open("datasource_" + name + ".json", "w") as file:# 使用json.dump()函數將數據轉換為JSON格式后寫入文件json.dump(ret_json, file)return ret_jsonelse:print("Failed to retrieve dashboards.")def set_datasource_detail(datasource_json, password="123"):# del datasource_json["uid"]# datasource_json["name"] = datasource_json["name"] + "03"datasource_json["secureJsonData"] = {'basicAuthPassword': password}new_json_obj = json.dumps(datasource_json)print(new_json_obj)response = requests.post(f'{new_grafana_url}/datasources', data=new_json_obj, headers=headers,auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")def set_datasource_detail(datasource_json, es_url=new_es_url,password=new_es_passwd):# del datasource_json["uid"]# datasource_json["name"] = datasource_json["name"] + "03"if "elasticsearch" == datasource_json["type"]:datasource_json["url"] = new_es_urldatasource_json["secureJsonData"] = {'basicAuthPassword': password}new_json_obj = json.dumps(datasource_json)print(new_json_obj)response = requests.post(f'{new_grafana_url}/datasources', data=new_json_obj, headers=headers,auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")def del_datasource_detail(datasource_id):response = requests.delete(f'{new_grafana_url}/datasources/{datasource_id}', headers=headers,auth=HTTPBasicAuth(username, passwd), verify=False)if response.status_code == 200:ret_json = json.loads(response.text)return ret_jsonelse:print("Failed to retrieve dashboards.")# 獲文件夾列表
def get_folders(url):response = requests.get(f'{url}/folders', headers=headers, auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:return json.loads(response.text)else:print("Failed to retrieve dashboards.")def save_folder_detail(folder_uid):response = requests.get(f'{grafana_url}/folders/{folder_uid}', headers=headers,auth=HTTPBasicAuth(username, passwd), verify=False)if response.status_code == 200:ret_json = json.loads(response.text)print(ret_json)name = ret_json["title"]# 打開文件(若不存在則創建)并寫入JSON數據with open("folder_" + name + ".json", "w") as file:# 使用json.dump()函數將數據轉換為JSON格式后寫入文件json.dump(ret_json, file)return ret_jsonelse:print("Failed to retrieve dashboards.")def set_folder_detail(folder_json):# datasource_json["name"] = datasource_json["name"] + "03"new_json_obj = {"title": folder_json["title"], "uid": folder_json["uid"]}json_obj = json.dumps(new_json_obj)print(new_json_obj)response = requests.post(f'{new_grafana_url}/folders', data=json_obj, headers=headers,auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")# 獲取所有儀表盤列表
def get_dashboards():response = requests.get(f'{grafana_url}/search', headers=headers, auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")def save_dashboard_detail(dashboard_id , folder_id):response = requests.get(f'{grafana_url}/dashboards/uid/{dashboard_id}', headers=headers,auth=HTTPBasicAuth(username, passwd), verify=False)if response.status_code == 200:ret_json = json.loads(response.text)print(ret_json)dashboard = ret_json["dashboard"]name = dashboard["title"]if folder_id == None:# 打開文件(若不存在則創建)并寫入JSON數據with open("dashboard_" + name + ".json", "w") as file:# 使用json.dump()函數將數據轉換為JSON格式后寫入文件json.dump(ret_json, file)else:with open("dashboard_folder" + str(folder_id) + "_" + name + ".json", "w") as file:# 使用json.dump()函數將數據轉換為JSON格式后寫入文件json.dump(ret_json, file)return ret_jsonelse:print("Failed to retrieve dashboards.")def set_dashboard_detail(dashboard_json):folderUid = dashboard_json["meta"]["folderUid"]del  dashboard_json["meta"]#dashboard = file_json["dashboard"]dashboard_json["folderUid"] = folderUiddashboard_json["overwrite"] = Truedashboard_json["dashboard"]["id"] = NonedashboardJson = json.dumps(dashboard_json)print(f"{dashboardJson}")response = requests.post(f'{new_grafana_url}/dashboards/import', data=dashboardJson, headers=headers,auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")# 創建新的儀表盤
def create_new_dashboard(title):data = {"overwrite": False,"dashboard": {"id": None,"uid": "","title": title,# ...其他配置項...},"folderId": 0,"message": ""}headers = {'Authorization': f'Bearer {api_key}','Content-Type': 'application/json'}response = requests.post(f'{grafana_url}/dashboards/db', json=data, headers=headers)if response.status_code == 200:return response.json().get('slug')else:print("Failed to create new dashboard.")# 更新現有儀表盤
def update_existing_dashboard(dashboard_slug, title):data = {"overwrite": True,"dashboard": {"id": None,"uid": "","title": title,# ...其他配置項...},"folderId": 0,"message": ""}headers = {'Authorization': f'Bearer {api_key}','Content-Type': 'application/json'}response = requests.put(f'{grafana_url}/dashboards/{dashboard_slug}', json=data, headers=headers)if response.status_code == 200:return response.json().get('slug')else:print("Failed to update existing dashboard.")# 刪除指定儀表盤
def delete_dashboard(dashboard_slug):headers = {'Authorization': f'Bearer {api_key}'}response = requests.delete(f'{grafana_url}/dashboards/{dashboard_slug}', headers=headers)if response.status_code == 200:print("Dashboard deleted successfully.")else:print("Failed to delete the dashboard.")# 測試函數
if __name__ == "__main__":# # 清空所有數據源# datasources = get_datasources()# for datasource in datasources:#     # print(datasource["id"])#     datasource_detail = del_datasource_detail(datasource["id"])#     print(datasource_detail)current_dir = os.getcwd()file_names = os.listdir(current_dir)# 獲取所有數據源并保存到磁盤datasources = get_datasources()for datasource in datasources:# print(datasource["id"])datasource_detail = save_datasource_detail(datasource["id"])print(datasource_detail)#  數據源導入# for file_name in file_names:#     if file_name.startswith("datasource") & file_name.endswith(".json"):#         print(file_name)##         with open(file_name, 'r') as f:#             file_json = json.load(f)#         ret = set_datasource_detail(file_json, new_es_url,new_es_passwd)# 獲取所有文件夾并保存到磁盤folders = get_folders(grafana_url)for folder in folders:print(folder["title"])folder_detail = save_folder_detail(folder["uid"])print(folder_detail)# 文件夾導入# for file_name in file_names:#     if file_name.startswith("folder") & file_name.endswith(".json"):#         print(file_name)#         with open(file_name, 'r') as f:#             file_json = json.load(f)#         ret = set_folder_detail(file_json)# 獲取所有儀表盤列表dashboards = get_dashboards()for board in dashboards:# if type_folder==board["type"]:#     print(board["title"])if type_dashboard == board["type"]:print(board["title"])save_dashboard_detail(board["uid"],board["folderId"])# 儀表盤導入# for file_name in file_names:#     if file_name.startswith("dashboard") & file_name.endswith(".json"):#         print(file_name)#         with open(file_name, 'r') as f:#             file_json = json.load(f)#         ret = set_dashboard_detail(file_json)# # 創建新的儀表盤# new_dashboard_slug = create_new_dashboard("New Dashboard")# print(f"Created a new dashboard with slug: {new_dashboard_slug}")## # 更新現有儀表盤# updated_dashboard_slug = update_existing_dashboard(new_dashboard_slug, "Updated Dashboard Title")# print(f"Updated an existing dashboard with slug: {updated_dashboard_slug}")## # 刪除指定儀表盤# delete_dashboard(updated_dashboard_slug)

二、grafana 批量視圖恢復

import requests
import json
import urllib3
import osfrom requests.auth import HTTPBasicAuthfilename_folders_map = "folders_map.json"
type_folder = "dash-folder"
type_dashboard = "dash-db"# Grafana服務器地址及API密鑰
grafana_url = "https://127.0.0.1:30301/api"
api_key = "YOUR_API_KEY"
username = "admin"
passwd = "admin123"
requests.packages.urllib3.disable_warnings()
# new_grafana_url = "https://127.0.0.2:30301/api"
# new_es_url = "https://quickstart-es-data-nodes.es8:9200"
# new_es_passwd = "new_es_passwd "
new_grafana_url = "https://127.0.0.1:30301/api"
new_es_url = "https://quickstart-es-data-nodes.es8:9200"
new_es_passwd = "new_es_passwd "old_domain = 'traefik.kidsi4.cn'
new_domain = 'web.bcs2sz.com'headers = {'Content-Type': 'application/json'
}# 獲取數據源列表
def get_datasources():response = requests.get(f'{new_grafana_url}/datasources', headers=headers, auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")def save_datasource_detail(datasource_id):response = requests.get(f'{grafana_url}/datasources/{datasource_id}', headers=headers,auth=HTTPBasicAuth(username, passwd), verify=False)if response.status_code == 200:ret_json = json.loads(response.text)print(ret_json)name = ret_json["name"]# 打開文件(若不存在則創建)并寫入JSON數據with open("datasource_" + name + ".json", "w") as file:# 使用json.dump()函數將數據轉換為JSON格式后寫入文件json.dump(ret_json, file)return ret_jsonelse:print("Failed to retrieve dashboards.")def set_datasource_detail(datasource_json, password="123"):# del datasource_json["uid"]# datasource_json["name"] = datasource_json["name"] + "03"datasource_json["secureJsonData"] = {'basicAuthPassword': password}new_json_obj = json.dumps(datasource_json)print(new_json_obj)response = requests.post(f'{new_grafana_url}/datasources', data=new_json_obj, headers=headers,auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")def set_datasource_detail(datasource_json, es_url=new_es_url,password=new_es_passwd):# del datasource_json["uid"]# datasource_json["name"] = datasource_json["name"] + "03"if "elasticsearch" == datasource_json["type"]:datasource_json["url"] = new_es_urldatasource_json["secureJsonData"] = {'basicAuthPassword': password}new_json_obj = json.dumps(datasource_json)print(new_json_obj)response = requests.post(f'{new_grafana_url}/datasources', data=new_json_obj, headers=headers,auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")def del_datasource_detail(datasource_id):response = requests.delete(f'{new_grafana_url}/datasources/{datasource_id}', headers=headers,auth=HTTPBasicAuth(username, passwd), verify=False)if response.status_code == 200:ret_json = json.loads(response.text)return ret_jsonelse:print("Failed to retrieve dashboards.")# 獲文件夾列表
def get_folders(url):response = requests.get(f'{url}/folders', headers=headers, auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:return json.loads(response.text)else:print("Failed to retrieve dashboards.")def save_folder_detail(folder_uid):response = requests.get(f'{grafana_url}/folders/{folder_uid}', headers=headers,auth=HTTPBasicAuth(username, passwd), verify=False)if response.status_code == 200:ret_json = json.loads(response.text)print(ret_json)name = ret_json["title"]# 打開文件(若不存在則創建)并寫入JSON數據with open("folder_" + name + ".json", "w") as file:# 使用json.dump()函數將數據轉換為JSON格式后寫入文件json.dump(ret_json, file)return ret_jsonelse:print("Failed to retrieve dashboards.")def set_folder_detail(folder_json):# datasource_json["name"] = datasource_json["name"] + "03"new_json_obj = {"title": folder_json["title"], "uid": folder_json["uid"]}json_obj = json.dumps(new_json_obj)print(new_json_obj)response = requests.post(f'{new_grafana_url}/folders', data=json_obj, headers=headers,auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")# 獲取所有儀表盤列表
def get_dashboards():response = requests.get(f'{grafana_url}/search', headers=headers, auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")def save_dashboard_detail(dashboard_id):response = requests.get(f'{grafana_url}/dashboards/uid/{dashboard_id}', headers=headers,auth=HTTPBasicAuth(username, passwd), verify=False)if response.status_code == 200:ret_json = json.loads(response.text)print(ret_json)dashboard = ret_json["dashboard"]name = dashboard["title"]# 打開文件(若不存在則創建)并寫入JSON數據with open("dashboard_" + name + ".json", "w") as file:# 使用json.dump()函數將數據轉換為JSON格式后寫入文件json.dump(ret_json, file)return ret_jsonelse:print("Failed to retrieve dashboards.")def set_dashboard_detail(dashboard_json):folderUid = dashboard_json["meta"]["folderUid"]del  dashboard_json["meta"]#dashboard = file_json["dashboard"]dashboard_json["folderUid"] = folderUiddashboard_json["overwrite"] = Truedashboard_json["dashboard"]["id"] = NonedashboardJson = json.dumps(dashboard_json)print(f"{dashboardJson}")response = requests.post(f'{new_grafana_url}/dashboards/import', data=dashboardJson, headers=headers,auth=HTTPBasicAuth(username, passwd),verify=False)if response.status_code == 200:print(json.loads(response.text))return json.loads(response.text)else:print("Failed to retrieve dashboards.")# 創建新的儀表盤
def create_new_dashboard(title):data = {"overwrite": False,"dashboard": {"id": None,"uid": "","title": title,# ...其他配置項...},"folderId": 0,"message": ""}headers = {'Authorization': f'Bearer {api_key}','Content-Type': 'application/json'}response = requests.post(f'{grafana_url}/dashboards/db', json=data, headers=headers)if response.status_code == 200:return response.json().get('slug')else:print("Failed to create new dashboard.")# 更新現有儀表盤
def update_existing_dashboard(dashboard_slug, title):data = {"overwrite": True,"dashboard": {"id": None,"uid": "","title": title,# ...其他配置項...},"folderId": 0,"message": ""}headers = {'Authorization': f'Bearer {api_key}','Content-Type': 'application/json'}response = requests.put(f'{grafana_url}/dashboards/{dashboard_slug}', json=data, headers=headers)if response.status_code == 200:return response.json().get('slug')else:print("Failed to update existing dashboard.")# 刪除指定儀表盤
def delete_dashboard(dashboard_slug):headers = {'Authorization': f'Bearer {api_key}'}response = requests.delete(f'{grafana_url}/dashboards/{dashboard_slug}', headers=headers)if response.status_code == 200:print("Dashboard deleted successfully.")else:print("Failed to delete the dashboard.")# 測試函數
if __name__ == "__main__":# # 清空所有數據源datasources = get_datasources()for datasource in datasources:# print(datasource["id"])datasource_detail = del_datasource_detail(datasource["id"])print(datasource_detail)current_dir = os.getcwd()file_names = os.listdir(current_dir)#  數據源導入for file_name in file_names:if file_name.startswith("datasource") & file_name.endswith(".json"):print(file_name)with open(file_name, 'r') as f:file_json = json.load(f)ret = set_datasource_detail(file_json, new_es_url,new_es_passwd)# 獲取所有文件夾并保存到磁盤# folders = get_folders(grafana_url)# for folder in folders:#     print(folder["title"])#     folder_detail = save_folder_detail(folder["uid"])#     print(folder_detail)# 文件夾導入# current_dir = os.getcwd()# file_names = os.listdir(current_dir)for file_name in file_names:if file_name.startswith("folder") & file_name.endswith(".json"):print(file_name)with open(file_name, 'r') as f:file_json = json.load(f)ret = set_folder_detail(file_json)# 獲取所有儀表盤列表# dashboards = get_dashboards()# for board in dashboards:#     # if type_folder==board["type"]:#     #     print(board["title"])#     if type_dashboard == board["type"]:#         print(board["title"])#         save_dashboard_detail(board["uid"])# 儀表盤導入# current_dir = os.getcwd()# file_names = os.listdir(current_dir)for file_name in file_names:if file_name.startswith("dashboard") & file_name.endswith(".json"):print(file_name)with open(file_name, 'r') as f:file_json = json.load(f)# 域名處理Json_str2 = json.dumps(file_json)Json_str3= Json_str2.replace(old_domain,new_domain)Json_str4 = Json_str3.replace(old_domain, new_domain)json5 = json.loads( Json_str4 )ret = set_dashboard_detail(json5)# # 創建新的儀表盤# new_dashboard_slug = create_new_dashboard("New Dashboard")# print(f"Created a new dashboard with slug: {new_dashboard_slug}")## # 更新現有儀表盤# updated_dashboard_slug = update_existing_dashboard(new_dashboard_slug, "Updated Dashboard Title")# print(f"Updated an existing dashboard with slug: {updated_dashboard_slug}")## # 刪除指定儀表盤# delete_dashboard(updated_dashboard_slug)

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/86151.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/86151.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/86151.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

.Net Framework 4/C# 關鍵字(非常用,持續更新...)

一、is 關鍵字 is 關鍵字用于檢查對象是否于給定類型兼容,如果兼容將返回 true,如果不兼容則返回 false,在進行類型轉換前,可以先使用 is 關鍵字判斷對象是否與指定類型兼容,如果兼容才進行轉換,這樣的轉換是安全的。 例如有:首先創建一個字符串對象,然后將字符串對象隱…

露亦如電 · 時之沙 | 讓遺憾在灰燼里隨風而去

注:略作重排,未整理去重。 一個人最了不起的能力:快速翻篇 原創 十點邀約作者 棠唐 2022 年 11 月 29 日 20:12 福建 《了凡四訓》有言:“從前種種,譬如昨日死;從后種種,譬如今日生。” 人生猶…

python爬蟲:Newspaper3k 的詳細使用(好用的新聞網站文章抓取和解析的Python庫)

更多內容請見: 爬蟲和逆向教程-專欄介紹和目錄 文章目錄 一、Newspaper3k 概述1.1 Newspaper3k 介紹1.2 主要功能1.3 典型應用場景1.4 安裝二、基本用法2.2 提取單篇文章的內容2.2 處理多篇文檔三、高級選項3.1 自定義配置3.2 分析文章情感四、實戰案例4.1 構建新聞摘要聚合器…

FastAPI安全機制:從OAuth2到JWT的魔法通關秘籍

title: FastAPI安全機制:從OAuth2到JWT的魔法通關秘籍 date: 2025/06/07 08:40:35 updated: 2025/06/07 08:40:35 author: cmdragon excerpt: FastAPI 的安全機制基于 OAuth2 規范、JWT 和依賴注入系統三大核心組件,提供了標準化的授權框架和無狀態的身份驗證。OAuth2 密碼流…

超大規模芯片驗證:基于AMD VP1902的S8-100原型驗證系統實測性能翻倍

引言&#xff1a; 隨著AI、HPC及超大規模芯片設計需求呈指數級增長原型驗證平臺已成為芯片設計流程中驗證復雜架構、縮短迭代周期的核心工具。然而&#xff0c;傳統原型驗證系統受限于單芯片容量&#xff08;通常<5000萬門&#xff09;、多芯片分割效率及系統級聯能力&#…

python電子學會三級的零碎筆記

1、join (1) .join(s)\n?&#xff1a;這種方式首先將列表s中的每個元素通過空格連接成一個字符串&#xff0c;然后在字符串末尾添加一個換行符\n。 ?示例?&#xff1a;如果s [a, b, c]&#xff0c;則 .join(s)\n的結果是a b c\n&#xff0c;寫入文件時所有元素會在一行…

TongWeb7.0動態密鑰說明

為解決TongWeb密碼硬編碼問題&#xff0c;TongWeb7.0.4.9_M5及之后版本采用動態密鑰&#xff0c;在使用過程或升級過程中可能會遇到密碼加密異常問題。對其做一個說明&#xff1a; 在TongWeb單節點情況下&#xff0c;根節點和通過domain命令建的域&#xff0c;數據源用戶名和密…

【LLMs篇】14:擴散語言模型的理論優勢與局限性

項目內容論文標題擴散語言模型的理論優勢與局限性 (Theoretical Benefit and Limitation of Diffusion Language Model)研究背景擴散語言模型&#xff08;尤其是掩碼擴散模型 MDM&#xff09;因其并行生成能力被認為有潛力超越自回歸模型&#xff0c;但其在效率-準確性上的權衡…

歡樂熊大話藍牙知識14:用 STM32 或 EFR32 實現 BLE 通信模塊:從0到藍牙,你也能搞!

&#x1f680; 用 STM32 或 EFR32 實現 BLE 通信模塊&#xff1a;從0到藍牙&#xff0c;你也能搞&#xff01; “我能不能自己用 STM32 或 EFR32 實現一個 BLE 模塊&#xff1f;” 答案當然是&#xff1a;能&#xff01;還能很帥&#xff01; &#x1f468;?&#x1f3ed; 前…

在C語言中使用UUID作為AES加密密鑰

在C語言中使用UUID作為AES加密密鑰 編譯依賴安裝示例代碼編譯和運行關鍵點說明![在這里插入圖片描述](https://i-blog.csdnimg.cn/direct/0df1f1d803cd40688f6d58a9d0e1f1d9.png)注意事項編譯依賴安裝 運行環境位centos8 Linux 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec …

全面解析:tzst 歸檔格式的先進性與跨平臺文件管理指南

您可以通過 star 我固定的 GitHub 存儲庫來支持我&#xff0c;謝謝&#xff01;以下是我的一些 GitHub 存儲庫&#xff0c;很有可能對您有用&#xff1a; tzst Xget Prompt Library 原文 URL&#xff1a;https://blog.xi-xu.me/2025/06/07/comprehensive-guide-to-tzst-arch…

C++ 設計模式 《小明的奶茶加料風波》

&#x1f468;?&#x1f393; 模式名稱&#xff1a;裝飾器模式&#xff08;Decorator Pattern&#xff09; &#x1f466; 小明最近上線了校園奶茶配送功能&#xff0c;業務火爆&#xff0c;大家都在加料&#xff1a; 有的同學要加波霸 &#x1f7e4;&#xff0c;有的要加椰果…

Java 并發編程系列(上篇):多線程深入解析

一、開篇&#xff1a;走進 Java 并發編程世界 在現代軟件開發中&#xff0c;充分利用多核 CPU 的計算能力至關重要&#xff0c;Java 并發編程為我們提供了實現這一目標的工具。從簡單的多線程任務并行執行&#xff0c;到復雜的高并發系統設計&#xff0c;掌握并發編程是進階 Ja…

[逆向工程] C實現過程調試與鉤子安裝(二十七)

[逆向工程] C實現過程調試與鉤子安裝&#xff08;二十七&#xff09; 引言 在現代逆向工程和調試領域&#xff0c;能夠動態監控和操控進程執行非常關鍵。本篇文章將全面講解如何使用 C 編寫一個進程調試器——hookdbg64.exe&#xff0c;實現對目標進程的附加、監控 WriteFile…

分頁查詢的實現

第一步&#xff1a;導入pom依賴 <!--配置PageHelper分頁插件--><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.4.6</version><exclusions>…

JDK17 Http Request 異步處理 源碼刨析

為什么可以異步&#xff1f; #調用起始源碼 // 3. 發送異步請求并處理響應 CompletableFuture future client.sendAsync( request, HttpResponse.BodyHandlers.ofString() // 響應體轉為字符串 ).thenApply(response -> { // 狀態碼檢查&#xff08;非200系列拋出異常&…

會計 - 合并4 - 或有對價的會計處理

一、多次交易(構成一攬子交易)形成非同一控制下企業合并 構成一攬子交易的,在取得控制權時確認長期股權投資;取得控制權之前已支付的款項應作為預付投資款項(通常以”預付賬款“科目核算)處理。 滿足以下一種或多種情況的,通常應將多次交易事項作為“一攬子交易”進行會…

【HTTP三個基礎問題】

面試官您好&#xff01;HTTP是超文本傳輸協議&#xff0c;是互聯網上客戶端和服務器之間傳輸超文本數據&#xff08;比如文字、圖片、音頻、視頻等&#xff09;的核心協議&#xff0c;當前互聯網應用最廣泛的版本是HTTP1.1&#xff0c;它基于經典的C/S模型&#xff0c;也就是客…

NLP中的input_ids是什么?

在自然語言處理(NLP)中,input_ids 是什么 在自然語言處理(NLP)中,input_ids 是將文本轉換為模型可處理的數字表示后的結果,是模型輸入的核心參數之一。 一、基本概念 文本數字化 原始文本(如 “Hello world!”)無法直接被模型處理,需要通過分詞器(Tokenizer) 將其…

?? Linux Docker 基本命令參數詳解

&#x1f433; Linux Docker 基本命令參數詳解 &#x1f4d8; 1. Docker 簡介 Docker 是一個開源的容器化平臺&#xff0c;它通過將應用及其依賴打包到一個輕量級、可移植的容器中&#xff0c;從而實現跨平臺運行。Docker 采用 C/S 架構&#xff0c;服務端稱為 Docker Daemon&a…