
Operating System
1. Overview 什么是操作系统? 硬件角度: 管理硬件:将复杂的,具备不同功能的硬件资源纳入统一管理。 对硬件进行抽象:抽象成不依赖具体硬件特性的资源。 将有限的,离散的资源高效地抽象成无限的、连续的资源,并提交接口给上层系统调用。 ...

1. Overview 什么是操作系统? 硬件角度: 管理硬件:将复杂的,具备不同功能的硬件资源纳入统一管理。 对硬件进行抽象:抽象成不依赖具体硬件特性的资源。 将有限的,离散的资源高效地抽象成无限的、连续的资源,并提交接口给上层系统调用。 ...

Kubernetes 场景:管理容器化的工作负载和服务,可促进声明式配置和自动化 功能:服务发现和负载均衡、存储编排、自动部署和回滚、自动完成装箱计算、自我修复、密钥与配置管理 ...

Redis Data Structure 0. Redis Object 1 2 3 4 5 6 7 struct RedisObject { int4 type; // 4bits \ int4 enconding; // 4bits = 4bytes int24 lru; // 24bits / int32 refcount; // 4bytes void* ptr; // 8bytes (64bit-system) } robj; RedisObject对于不通对象都是相同的,对于这样的结构,每个都需要16byte的空间。 ...

Design Pattern 1. Creational Patterns 1.1.Factory Method 工厂方法模式是一种创建型设计模式, 其在父类中提供一个创建对象的方法, 允许子类决定实例化对象的类型。 Usage 无法预知对象确切类别及其依赖关系。(只需要开发新的创建者子类, 然后重写其工厂方法) 希望用户能扩展软件库或框架的内部组件。 如果希望复用现有对象来节省系统资源, 而不是每次都重新创建对象。 Advantages 避免创建者和具体产品之间的紧密耦合。 单一职责原则。 将产品创建代码放在程序的单一位置, 从而使得代码更容易维护。 开闭原则。 无需更改现有客户端代码, 可以在程序中引入新的产品类型。 Disadvantages 应用工厂方法模式需要引入许多新的子类, 代码可能会因此变得更复杂。 最好的情况是将该模式引入创建者类的现有层次结构中。 Demo 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 public abstract class NumberFormat extends Format { private static NumberFormat getInstance(Locale desiredLocale, int choice) { LocaleProviderAdapter adapter; adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, desiredLocale); NumberFormat numberFormat = getInstance(adapter, desiredLocale, choice); if (numberFormat == null) { numberFormat = getInstance(LocaleProviderAdapter.forJRE(), desiredLocale, choice); } return numberFormat; } private static NumberFormat getInstance(LocaleProviderAdapter adapter, Locale locale, int choice) { NumberFormatProvider provider = adapter.getNumberFormatProvider(); NumberFormat numberFormat = null; switch (choice) { case NUMBERSTYLE: numberFormat = provider.getNumberInstance(locale); break; case PERCENTSTYLE: numberFormat = provider.getPercentInstance(locale); break; case CURRENCYSTYLE: numberFormat = provider.getCurrencyInstance(locale); break; case INTEGERSTYLE: numberFormat = provider.getIntegerInstance(locale); break; } return numberFormat; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 // Calendar 三个子类,都可以调用getInstance() -> createClendar // BuddhistCalendar // GregorianCalendar // JapaneseImperialCalendar private static Calendar createCalendar(TimeZone zone, Locale aLocale) { CalendarProvider provider = LocaleProviderAdapter.getAdapter(CalendarProvider.class, aLocale) .getCalendarProvider(); if (provider != null) { try { return provider.getInstance(zone, aLocale); } catch (IllegalArgumentException iae) { // fall back to the default instantiation } } Calendar cal = null; if (aLocale.hasExtensions()) { String caltype = aLocale.getUnicodeLocaleType("ca"); if (caltype != null) { switch (caltype) { case "buddhist": cal = new BuddhistCalendar(zone, aLocale); break; case "japanese": cal = new JapaneseImperialCalendar(zone, aLocale); break; case "gregory": cal = new GregorianCalendar(zone, aLocale); break; } } } if (cal == null) { // If no known calendar type is explicitly specified, // perform the traditional way to create a Calendar: // create a BuddhistCalendar for th_TH locale, // a JapaneseImperialCalendar for ja_JP_JP locale, or // a GregorianCalendar for any other locales. // NOTE: The language, country and variant strings are interned. if (aLocale.getLanguage() == "th" && aLocale.getCountry() == "TH") { cal = new BuddhistCalendar(zone, aLocale); } else if (aLocale.getVariant() == "JP" && aLocale.getLanguage() == "ja" && aLocale.getCountry() == "JP") { cal = new JapaneseImperialCalendar(zone, aLocale); } else { cal = new GregorianCalendar(zone, aLocale); } } return cal; } 1.2.Abstract Factory 抽象工厂模式是一种创建型设计模式, 它能创建一系列相关的对象, 而无需指定其具体类。 ...

MySQL基础笔记 1. 数据库简介 1.1.数据库的优势 使用数据库的优点 实现数据持久化 使用完整的管理系统,易于查询 成本低,开源,性能高,使用简单 移植性好 1.2.数据库的相关概念 DB:(Database)即数据库本身,保存有组织数据的容器 DBMS:(Database Manage System)数据库管理系统,即创建、使用数据库的系统 SQL:(Structured Quey Language)结构化查询语言 常用的数据库类型:MySQL,Oracle,DB2,SqlServer(只限win) 注意:SQL不是某个特定版本才有的,而是泛指一种结构化查询用的语言 ...